w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 661 forks source link

[css-fonts-4] Make behaviour of new auto values on @font-face properties clearer #9485

Open wezm opened 1 year ago

wezm commented 1 year ago

CSS Fonts Level 4 adds an auto value to font-weight, font-style, and font-stretch in @font-face rules and uses it as the initial value of these properties. The spec does not provide much detail on how this auto value works. This is the only note I could find:

The auto values for these three descriptors have the following effects:

  • For font selection purposes, the font is selected as if the appropriate initial value is chosen
  • For variation axis clamping, clamping does not occur

I think that this needs to be expanded and that "appropriate initial value" defined.

Looking over #2485 clarified some things for me that I think should be added to the spec. Specifically taking font-weight as an example it seems that auto acts as an alias for normal for fonts without a wght axis, matching the behaviour of CSS Fonts Level 3. For fonts with a wght axis it seems that it acts as a sort of wildcard equivalent to 1 1000.

svgeesus commented 9 months ago

I think that this needs to be expanded and that "appropriate initial value" defined.

Ah, I see. In https://github.com/w3c/csswg-drafts/commit/9a6e7049b9f096a2551af0ee546241da28433c99 the initial value was "normal" for all three font-weight, font-style and font-width and that would be used for font selection purposes. So "appropriate initial value" made sense. But in https://github.com/w3c/csswg-drafts/commit/36f80a0c77378ee511f1f67ecb08182be3cfeb91 that was changed to auto because of https://github.com/w3c/csswg-drafts/issues/2485#issuecomment-431893656 so now it needs to explicitly say 'normal`, for font selection.

And for variation handling, it means no clamping is applied.

svgeesus commented 9 months ago

@wezm do the changes in https://github.com/w3c/csswg-drafts/commit/02251acdacffe25902d0f8618e1586016a6fde01 cover it?

wezm commented 9 months ago

@svgeesus hmm are the changes right? E.g. for font-weight normal means 400 and if that was used with a variable font with a wght axis ranging from 500 to 900 the new text suggests to me that that font would not be selected, whereas I think the intention of auto is that it would be selected?

svgeesus commented 9 months ago

Good point, this interacts with