Re: [csswg-drafts] Interoperable font metrics (#4792)

Thanks for the feedback!

Regarding `advance-override`: Though it looks very similar to the `letter-spacing` CSS property, they are actually for different purposes. `letter-spacing` is for good typography, while `advance-override` is proposed mainly to reduce CLS when switching from a local fallback font to a web font. Therefore, they should work in different ways, and issues with `letter-spacing` (like #1518) do not necessarily apply here.

For the goal of reducing CLS, we want to match the text widths of the fallback font and web font, which requires `advance-override` to adjust the advance of each glyph†, not just the spacing between glyphs (so, we do want extra space at the end of runs). In this way, the width difference between fallback font and web font can be minimized. In the best case, if we are using monospace, we can even perfectly match the widths and get 0 CLS by setting `advance-override: x - y`, where `x` and `y` are the character widths of the web font and fallback, respectively; If we override the spacing between glyphs only, the adjusted with is always off by `x - y`.

Below are some examples where overriding the spacing leads to larger CLS when switching font:
- In a table where the column widths depend on text widths. We want to match the text width as much as possible to reduce the horizontal shifting of the cells
- In a line with multiple fonts, e.g. in [example 23 in the spec](https://drafts.csswg.org/css-text-3/#example-36282bb9:~:text=A%20given%20value%20of%20letter%2Dspacing%20only,element%20for%20which%20it%20is%20specified%3A), where we want spacing applied to the 2nd "b"
- In a line with mixed text and non-text inline elements
- When line wraps, the advance of the last character (very slightly) affects the total width and therefore affects where line breaks

Btw, this is also the reason we renamed it to `advance-override`: to emphasize what it actually overrides.

†  At a more detailed level ([illustration](https://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html)), advance = left side bearing (lsb) + glyph width + right side bearing (rsb). To match text width, `advance-override` should adjust lsb and rsb of every glyph, which is essentially adjusting the advance of every glyph.

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 15 September 2020 20:44:18 UTC