w3c / csswg-drafts

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

[css-inline] baseline synthesis: add ideographic embox and baseline offset #1961

Open macnmm opened 6 years ago

macnmm commented 6 years ago

https://drafts.csswg.org/css-inline/#baseline-synthesis

The most important metrics for CJK layout are the ideographic embox top and bottom, and the roman baseline offset (the distance from the embox bottom to the roman baseline). Ideographic character face, as described, is not that useful as a baseline for text, and I would recommend it be eliminated from the baseline selectors.

The distance from embox top to embox bottom in a square font is equal to the point size of that font. The offset of the embox to the Roman baseline is set so that the capital Roman letters are centered within that embox. Normally that also results in the CJK glyphs also to be centered in the embox.

The Text Top and Text Bottom baselines are overloaded to be "embox top and bottom", but it is unclear whether this is true for CJK fonts and non-CJK fonts in the same way, or that the ideographic embox can be obtained or calculated consistently for all fonts so they can be aligned correctly in a line together. I recommend disambiguating the text top and bottom from the CJK ideographic embox top and bottom.

@fantasai @frivoal @kojiishi @astearns

kojiishi commented 6 years ago

Thank you Nat for opening this discussion. I'm in favor, and I'm leaning to define it precisely to make it interoperable. The needs for an interoperable font metrics has been around, such as:

I briefly talked about the needs of interoeprable font metrics with @litherum and @boggydigital before, they seem to be interested in the discussion. I think we will need more metrics to be defined as we move on, because em box is probably not very useful for taller scripts such as Arabic, but it is still a good start.

In whatwg/html#2470, @jfkthame suggested that Gecko's em square is to use sTypoAscender and sTypoDescender normalized by UnitsPerEm, so that their sum should be 1em exactly.

I tried using this logic in Blink and it was quite successful at least for Latin and East Asian. This is also very similar to the OpenType Ideographic Em-Box fallback logic for CJK font.

Nat, does this definition look reasonable to you?

/cc @eaenet @FremyCompany @dbaron

dauwhe commented 5 years ago

Ideographic character face, as described, is not that useful as a baseline for text, and I would recommend it be eliminated from the baseline selectors.

We don't currently have baselines for ICF top or bottom. The only mention (apart from the synthesis section) seems to be in the definition of ideographic-ink, where it does appear to be a useful way to get the top of the text ink to align with the top of another box.

There does seem to be an open question on how to obtain necessary metrics from CJK fonts that lack them. And of course there's the original question of what baselines are needed :)