W3C home > Mailing lists > Public > public-css-archive@w3.org > February 2020

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

From: jfkthame via GitHub <sysbot+gh@w3.org>
Date: Wed, 19 Feb 2020 17:26:46 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-588341590-1582133205-sysbot+gh@w3.org>
It seems to me we could reasonably use CSS properties (not just font-face descriptors) here: something like `font-ascent`, `font-descent` and `font-linegap`, all with initial values of `auto` (meaning the browser derives metrics from the font or from system APIs or whatever), but with authors having the possibility to use percentages (to be resolved based on em size) instead.

`normal` line height would then be based on the used values of these metrics.

Then it might *also* be useful to have these as font-face descriptors, which would allow webfonts to override the result of `auto`, while leaving system fonts to do their normal thing. So authors could choose to take control just for a specific web font (using the descriptors), or to override the browser's `auto` behavior for arbitrary content in any font (using the properties). All this would be opt-in for authors, so there's no risk to existing content.

An author could then choose to do something like

    :root { font-ascent: 80%; font-descent: 20%; font-linegap: 10%; }

and expect to get consistent line-spacing behavior across browsers and platforms -- with the understanding that the result may not be the *same* as any given browser currently gives by default, but it's entirely under their control.

I suppose the metrics properties (not descriptors) should probably accept absolute lengths, calc expressions, etc. for completeness, although em-based percentages would usually be the most sensible thing to use.

The final piece would be to add a `from-font` value to each of these properties (distinct from `auto`), and define exactly what it means in terms of metrics from an OpenType font file; I would suggest the `sTypo*` values would be the appropriate choice. (This might require browsers to peek into font files, if system APIs don't provide the required metrics, so may be less convenient to implement.)

-- 
GitHub Notification of comment by jfkthame
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4792#issuecomment-588341590 using your GitHub account
Received on Wednesday, 19 February 2020 17:26:48 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:00 UTC