Re: [csswg-drafts] [css-fonts-5] font-size-adjust with missing metrics (#6384)

I thought that was exactly @fantasai's question, "should we be picking from the first available font that is able to provide the desired metric?"

ISTM there are actually two questions to consider here, and the answers might not necessarily be the same.

(1) When `font-size-adjust` is in effect with a given value (however it was specified), and we encounter a font in the fallback list that doesn't provide the relevant metric, how should we compute the adjustment for that font: (a) apply no adjustment, or (b) consider what the fallback for that metric would be, and base the adjustment on that.

(2) When `font-size-adjust` specifies the `from-font` keyword, but the [first available font](https://drafts.csswg.org/css-fonts-4/#first-available-font) doesn't provide the relevant metric, should we (a) treat this as `none`, so no adjustment will be applied to fallback fonts; (b) use the fallback value of the metric for the computed adjustment factor; or (c) look for the _first available font that is able to provide the desired metric_?

For (1), consider what happens in extreme cases. E.g. if I say
```
data:text/html,<div style="font-size:20px;font-size-adjust:cap-height 5">Hello سلام</div>
```
this is a (slightly odd) way of saying that I want the font sized such that its cap-height will be 100px. Now, suppose the primary font doesn't include Arabic letters, and the fallback that the browser picks does not provide a cap-height metric (which isn't unreasonable, as the concept has no clear meaning for Arabic script). How should the Arabic font be scaled, then? If we say "no adjustment is applied when the metric is missing", the Arabic text will end up tiny in comparison to the English. IMO using the same fallback heuristic as when resolving the `cap` unit for that font (which [Values & Units](https://drafts.csswg.org/css-values/#cap) says should use the ascent) is a better/less surprising result.

For (2), there isn't the same potential for an extreme mismatch if we say that a "missing" metric means no adjustment is applied; in that case, any fallback fonts used will simply not be adjusted, so the property just has no effect. I'm still not sure this is the best outcome, though. By using `font-size-adjust`, an author is asking that some dimension other than em-size should be kept consistent across any fallback fonts that get used. Even if there isn't a "real" metric available to resolve the adjustment factor (and so the adjustment applied to the primary font may be somewhat arbitrary), using a fallback heuristic will still provide the same benefit of harmonization across any fallback fonts that occur.

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


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

Received on Tuesday, 19 March 2024 11:55:20 UTC