Re: [csswg-drafts] [css-fonts-5] Add glyph scaling override descriptor to @font-face (#6075)

Thanks for filing this! Mostly agree with the suggested details above, with one doubt:

>     * Effect on `ascent-override`/`descent-override`/etc.? [Scales with the scale factor.]

Not sure about this one. `ascent-override` etc are not derived from the size of the glyphs, they're provided so that the author can *override* the metrics coming from the font and establish known line-spacing metrics that are *not* dependent on the specific font:

> the corresponding metric value is resolved as the given percentage multiplied by the used font size

(from css-fonts [4.11. Default font metrics overriding](https://drafts.csswg.org/css-fonts/#font-metrics-override-desc)).

In my understanding, the scale factor proposed here is not altering the "used font size". Given the simplest case of content like:

    <div style="font: 20px MyFont">foo bar

the specified, computed and used font sizes are all 20px. If MyFont has both metrics overrides and a glyph scaling descriptor applied:

    @font-face {
        font-family: MyFont;
        src: local("Arial");
        glyph-scale-factor: 90%;
        ascent-override: 90%;
        descent-override: 30%;
    }

the resulting ascent and descent metrics, used to compute the line box, remain 18px (90% * 20px) and 6px (30% * 20px) respectively. The glyph scaling just applies to the glyph outlines themselves (so this rule is "shrinking" Arial by 10%) and to metrics that are based on their measurements (the glyph advances, units like `ch` and `ex`, the *default* line metrics like ascent/descent that are derived from the font) but it does *not* affect anything based on `font-size`, which is unchanged.

One result of this -- which I think is correct -- is that `glyph-scale-factor` (or whatever it's called) will *normally* affect `ch`, `ex`, etc for the font to which it is applied. But in the event that the browser cannot determine these values from the font, and falls back to default heuristics as provided in [CSS Units & Values](https://drafts.csswg.org/css-values-4/#ch):

> In the cases where it is impossible or impractical to determine the measure of the “0” glyph, it must be assumed to be 0.5em wide by 1em tall. Thus, the ch unit falls back to 0.5em in the general case, and to 1em when it would be typeset upright (i.e. writing-mode is vertical-rl or vertical-lr and text-orientation is upright).

the resulting unit is *not* affected by the scale factor.



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


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

Received on Thursday, 4 March 2021 10:58:25 UTC