w3c / csswg-drafts

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

[css-fonts-4] 90-degree oblique means? #10084

Open SamB opened 7 months ago

SamB commented 7 months ago

So I noticed that https://drafts.csswg.org/css-fonts-4/#propdef-font-style lets you do this:

https://developer.mozilla.org/en-US/play?id=RwqvczHT9BBF%2FM%2Fui2mK8HA%2BoFvn%2FYaKPD7JcaMY3ES4yxk%2BckvLxowPWfSIOAOGeAIk6TiLXNHbgkrG

<body>Hi.</body>
/* A font with no italic/oblique face */
@import url(https://cdn.jsdelivr.net/npm/@fontsource/unifont/index.min.css);

body {
  font-family: Unifont;
  font-style: oblique 90deg;
}

In Chrome, this apparently just synthesizes a 12 degree oblique or whatever, which is apparently totally okay because the spec doesn't say which oblique faces a user agent may synthesize, so that's not super interesting.

Firefox seems to try to actually do 90 degree oblique, but it's a little hard to tell because I'm pretty sure the transformation isn't actually defined mathematically at that point?

What should actually happen here? It would probably be a good idea to at least add a note that ±90deg doesn't really make sense, suggest browsers consider clamping synthesis to a smaller range, and add wpt tests to make sure browsers at least don't crash if they actually try to synthesize that.

(Font designers would presumably be able to see that this does not make sense, and in any case, this spec doesn't seem to define validity for fonts themselves.)

svgeesus commented 7 months ago

CSS Values 4 only supports closed ranges and thus we have to write that values in the range 90deg to -90deg inclusive are allowed.

The OpenType spec gives the same range, but exclusive:

Valid numeric range: Values must be greater than -90 and less than +90.

You are correct that implementations may struggle with, say, a perfectly legal 89.999deg slope angle and the end result is unlikely to be typographically satisfying.

But just because a thing is possible does not mean it should be done; I don't see us declaring that slope angles greater than 60 degrees are silly in the same way that we don't prevent setting the width of <body> to 2px.