Re: [csswg-drafts] [css-fonts-4] font-display: optional without relayout (#4108)

> > However, we can't know whether a font is used without actually rendering the document.
> 
> I don't understand what you mean here; this seems obviously false. You know when a font is used after _styling_ a document; the render is much later in the pipeline.

Sorry if I'm not using the accurate terms.

In that way, we still need a forced style recalc to decide whether to load the font. When to do that remains quite tricky. Besides, that's not a cheap task, and the computed style will be invalidated after the font loads (which is at least what's happening in Blink), which is something we'd like to avoid.

> 
> > So If authors want to ensure no extra rendering while maximizing the chance that the font is used, do they have to force loading it with Font Loading API or `<link rel="preload">`, in combination with optional?
> 
> Yes. That'll give the page vital milliseconds to pull down the font (or load it from disk cache) before the page is otherwise renderable, maximizing the chance it gets selected.
> 
> > The latest spec revision seems to solve the latter. Should we introduce something like font-display: important for the former?
> 
> The `optional` value was _always_ the latter; the name, the description, and the mechanics were all firmly aimed at "I'd like to use this font but it's _totally okay_ to render the text in whatever's available quickly".
> 
> `font-display: important` is just `font-display: block`, no? Or if it's not, that's because it's actually even _more_ restrictive than `block`, blocking rendering of the _entire page_ until the font is delivered (rather than just the text)?
> 
> Given that we already widely agree that `block` is a bad, user-hostile behavior, I don't see how an _even more_ hostile behavior would be something we want to add.

I don't think it's another `block`. I'm think of the following:
- When the `@font-face` rule is added
  - Start font loading immediately
  - Block rendering until the font loads, or after a short timeout (something like 100ms to match local cache latency)
- If the font fails to load before the timeout, it enters the failure period immediately

Authors should use it only when they want to maximize the chance to use locally cached fonts while reducing latency and layout shifting.

Maybe I should have called it `font-display: cache-friendly` earlier to better express it 😅

-- 
GitHub Notification of comment by xiaochengh
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4108#issuecomment-573224715 using your GitHub account

Received on Friday, 10 January 2020 22:09:03 UTC