Intent to Implement: CSS font-display

988 views
Skip to first unread message

Kenji Baheux

unread,
Sep 10, 2015, 9:13:26 PM9/10/15
to blink-dev, Kunihiko Sakamoto, taba...@chromium.org

Contact emails

Engineering: ksak...@chromium.org

Spec editors: taba...@chromium.org , kenji...@chromium.org

PM: kenji...@chromium.org


Spec

https://tabatkins.github.io/specs/css-font-display/


Summary

A new @font-face descriptor for controlling how a downloadable font renders before it is fully loaded.


Motivation

When using downloadable webfonts via @font-face, the user agent needs to know what to do while the font is actively loading. Most web browsers have adopted some form of timeout:



Browser

Timeout triggering fallback behavior

Fallback

to system font?

Swap when the web font is available?

Chrome 35+

3 seconds

yes

yes

Opera

3 seconds

yes

yes

Firefox

3 seconds*

yes

yes

Internet Explorer

0 seconds

yes

yes

Safari

no timeout

n/a

n/a


*: simplified view


The 3 seconds timeout is from the point where the user agent determined that a particular web font would be needed. Synthetic example:


Web fonts timeout.png


Font Loading API allows a developer to override some of the above behaviors, but that requires scripting, a non-trivial amount of effort, and ultimately doesn’t provide sufficient hooks to cover all reasonable cases. Additionally, the developer needs to either inline the loading script into their page, or else load an external library and introduce additional network latency before the fonts can be loaded, delaying text rendering.


Design/performance-conscious web developers have a good sense for the relative importance of a given web font for the intended user experience. This specification provides them the ability to control font timeout and rendering behavior. Specifically, it lets developers:


  • Define the font rendering strategy when text is ready to be painted: block, or paint with fallback.

  • Define the font rendering behavior once the desired font is available: rerender text with the new font, or leave it with the fallback.


In addition, providing our developers a simple mean to control the behavior is important in the following context:

  • user agent interventions such as “bailing out early on web fonts if we know that we'll hit the font timeout anyway” (assuming an absence of conflicting font-display directives; crbug; discussion thread on intervention-dev coming soon).

  • RAIL performance because publishers currently have to rely on third party font loaders to approximate some of these behaviors, which further delays the first meaningful paint (with/without web fonts).



Compatibility Risk

Medium.

Pluses and minuses:


- no browser implementation at the moment

+ small API footprint

+ sufficient level of consensus in the CSS working group for the purpose of this intent to implement

- the specification is not yet integrated in the CSS font level 4 specification or a CSS specification

= no major negative and unaddressed feedback from other browser vendors

+ high level of interest from developers:



Ongoing technical constraints

None.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes.


OWP launch tracking bug

crbug.com/530015


Link to entry on the feature dashboard

https://www.chromestatus.com/feature/4799947908055040


Requesting approval to ship?

Not yet.

Yoav Weiss

unread,
Sep 11, 2015, 2:03:18 AM9/11/15
to Kenji Baheux, blink-dev, Kunihiko Sakamoto, taba...@chromium.org
Yay!!! Let me know if I can help with reviews.

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

PhistucK

unread,
Sep 11, 2015, 3:31:43 AM9/11/15
to Yoav Weiss, Kenji Baheux, blink-dev, Kunihiko Sakamoto, taba...@chromium.org
The specification does not mention a time unit value, only keywords.
I think it should, because browsers may change their heuristics and alter the number of seconds for block and such.
If you want to give developers the control, give it all of the control.

font-display: block 10s;

font-display: swap 1s 4s;

Or, since we have two meaningful periods (a block period and a swap period), make it a shorthand, or just make it accept only time based units in addition to the keywords -
font-display: 1s 4s;
Which is -
font-display 1s (for block) 4s (for swap);

Or something like that.

While the keywords do provide more power, this provides the full power, I think.


PhistucK

Kenji Baheux

unread,
Sep 11, 2015, 3:43:44 AM9/11/15
to PhistucK, Yoav Weiss, blink-dev, Kunihiko Sakamoto, taba...@chromium.org
Yes, we initially had a time unit value with similar constructs.

The feedback from the CSS working group led us to this scoped down version.
We hope to revisit this point based on what we will learn from this initial foray.

Kenji Baheux

unread,
Sep 11, 2015, 4:24:20 AM9/11/15
to blink-dev, phis...@gmail.com, yo...@yoav.ws, ksak...@chromium.org, taba...@chromium.org
Posted a proposal to intervention-dev to discuss the "bail out early of web fonts on slow connections" idea.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

ja...@freshtilledsoil.com

unread,
Sep 14, 2015, 12:23:12 PM9/14/15
to blink-dev
Implementing this in CSS would be as close to perfect a solution as I've seen. I've been advocating styling fallbacks for immediate display since 2011, and if we can remove the requirement for JS to be involved that increases the ability to properly adopt a fully 'progressively enhanced' stance in how we design/build. Will gladly help in any way possible.

Kenji Baheux

unread,
Sep 24, 2015, 12:26:49 PM9/24/15
to ja...@freshtilledsoil.com, blink-dev
Thanks Jason for this great feedback and your kind offer.

In the related intervention, I mentioned that we would need font-adjust to guarantee the smooth and progressive enhancement of a font. It's something that I want to discuss with the large web font providers in order to achieve this at scale. If you have some ideas, feel free to chime in on the intervention thread.
Reply all
Reply to author
Forward
0 new messages