Open r12a opened 1 year ago
From Font style: the font-style
property:
oblique
<angle [-90deg,90deg]>
? Controls matching against an oblique face. Positive angles represent a clockwise slant; negative angles represent a counter-clockwise slant. The lack of an<angle>
represents 14deg. (Note that a font might internally provide its own mapping for "oblique", but the mapping within the font is disregarded.) Fractional and negative values are accepted; however, values less than -90deg or values greater than 90deg are invalid. If no oblique faces exist, and font-synthesis-style has the value auto, a synthetic oblique face will be generated.
So, this is already explicitly possible: set font-style
to the desired value, such as -14deg
and set font-synthesis-style
to auto.
Thanks for helping me find this, @svgeesus ! That's great.
Fwiw, i wrote a test - see https://github.com/w3c/character_phrase_tests/issues/56
Gecko appears to support negative oblique, but Blink and WebKit don't. I'll close this and raise bugs for the latter two.
There is a fly in this ointment that i think may be worth noting. I created another test that included N'Ko but also Arabic, Hebrew, and Ukrainian. It turns out that if there is a font with an italic face, the oblique value gives way to that font, which is, if i read it correctly, what the spec expects.
https://github.com/w3c/glyph_character_tests/issues/10
No font-family styling is set in the test page, so the result will be a little unpredictable because it relies on fallback fonts. In my case, the result is:
There is no italic font for N'Ko, so the oblique styling applies, the default Arabic font set by me in my browser also has no italic correspondence, so same result. For Hebrew and Ukrainian, the text does get rendered by fallback fonts which have italic versions. Consequently, the left-leaning oblique setting is not applied, and the italic font face is applied - however, these fonts lean to the right. Also note that the italic font uses very different shapes for some letters than the regular font in cyrillic.
CSS seems to currently be assuming that oblique and italics are the same thing, but i'm not sure that that always holds. This is shown clearly here, where the current mechanism spoils the attempt to have a left-leaning slant. It may also be that authors want to slant regular glyphs rather than introduce the quite different glyph shapes associated with 'italicisation' in cyrillic, or they may want to use the italic font face, but slant it to the left(?).
It seems to me that you can turn off oblique synthesis using font-synthesis-style: none, but i wonder whether there should be another value, perhaps synthesise
, that prevents the automatic default to a random italic font, and allows the author to slant an existing font face, even an italic one, in the opposite direction??
I forgot to mention that if you set the text to italic using font-style:italic
that also knocks out the left-leaning, even if no italic font exists.
After talking with the i18n group on a teleconf about this, I think we have few sub-issues here. Quite possibly they should all be filed as separate things, but since they stem from this discussion, here they are, to get started.
when asking for oblique specifically, falling back to italics is not a good idea. The paragraph that defines oblique seems in agreement with that, but the paragraph after that muddles the issue, and picks “a font to use which is closest to the requested angle” seemingly without regard for italics vs oblique. Going from oblique to italics is probably not intended, but that should be clarified.
“a font to use which is closest to the requested angle” may not be fine if the closest one doesn't have the same sign. Let's say you're asking for -12deg, and there's +10deg and +20deg. Clearly, +20deg is not what you want, but there's a fair chance that the direction of the slant matters more than the exact angle, and that you'd rather have synthetic -12deg rather than +10deg. For italics that might be debatable (correct letter-shape might matter more than correct direction, though maybe not), but for oblique it's pretty clear that you'd want the right direction, even if that means synthesis.
font-synthesis-style
(“controls whether user agents are allowed to synthesize oblique font faces when a font family lacks oblique faces.”) having only a choice of auto | none
where none
means “Synthesis of oblique faces is not allowed”. Seems not quite right, or at least insufficient. Turning off synthesis of oblique faces when italics is requested seems like the right thing to do, but as written, it also turns off synthesis of oblique faces when oblique is requested. Unlike italics, oblique is easy to synthesize. So, we might want a separate control to turn off synthetic oblique when oblique is requested (or we might not), but the may control that turns off oblique when italics is requested should not also turn off synthetic oblique when oblique is requested.
We don't seem to have a general system that deals with left leaning italics or obliques. I suspect we might want something like:
font-face
letting you know if a (non-variable) oblique or italics font face is left or right leaning.
Maybe: font-style: auto | normal | italic [left | right]? | oblique [left | right | <angle>{1,2}]?
When you don't specify left nor right (on a non variable font), the ua should probably generally assume right, unless the font technology has some built in indicator.font-style: normal | italic [left | right]? | oblique [left | right | <angle>]?
Then, if you've got italics (or oblique), but they're leaning the opposite way of what was requested, you don't use the provided font-face, and synthesize instead (if font-synthesis
allows).
In vertical writing mode, the glyphs may not be slanted to the left or right, but to the inline direction, but we can understand it as slanting the glyphs to a certain physical direction in horizontal writing mode, and then rotate the text 90 degrees clockwise, so I I think it's probably ok to use physical keywords here.
In vertical writing mode, the glyphs may not be slanted to the left or right, but to the inline direction, but we can understand it as slanting the glyphs to a certain physical direction in horizontal writing mode, and then rotate the text 90 degrees clockwise,
we may need to recall #2983 and #2869 on this point? for above cases, we may consider these as a part of normal italic with taking rightmost vertical line of character frame as baseline, although...
so I I think it's probably ok to use physical keywords here.
How about cases like applying italic over mixing N'Ko string with latin or cyrillic? I'm not familiar with N'Ko italics, but if inserted latin or cyrillic are leaning to right, we could want to have some dir (rtl/ltr) based value?
a font to use which is closest to the requested angle
Perhaps we should clarify that like this
a font to use which is closest to the requested angle and of the correct sign
The CSS Working Group just discussed [css-fonts] It should be possible to slant glyphs to the left for italics/oblique
, and agreed to the following:
RESOLVED; *if* a browser does synthesis of oblique, there SHOULD be at least one synthesized font in each direction
Some right-to-left writing systems italicise by sloping the letters to the left (ie. in the reading direction).
Here is an example from the N'Ko Kigelia font. The creators of the Kigelia font conducted research with the users and standardisation body for the N'Ko script what their preference was, and this was the user's preference for the default styling of N'Ko italics.
Some Hebrew authors also prefer to slope in the direction of reading, although this tends to be author preference.
The following is a photo of an Arabic newspaper letterhead. See the oblique text in the middle line.
The CSS font-synthesis properties don't provide any mechanism to indicate the direction of lean. Could we please add something to support these international users.
[This gap is being tracked at https://github.com/w3c/afrlreq/issues/17]