Open kojiishi opened 1 year ago
I think this is one way the font designer could have control over mojikumi tsume (and therefore to some extent aki), but I still have concerns. The tsume amount (e.g. -50%) and aki amount (e.g. +50%) should normally be equal, but the purpose of the tsume amount is to normalize punctuation widths to the JIS X 4051 spec, so then added aki can be consistently applied between all class combinations, resulting in line compression or expansion. This is fine in the case of full width monospaced text, but what of punctuation whose design is not half-and-half? What about proportional typesetting? This is where the JIS spec lacks detail, and where one would hope the font could guide what happens with features. I feel these narrowing features are only part of the solution and defined in such a way as being more generalized than to solve JIS X 4051 (and beyond) spacing issues specifically.
Last time I discussed internally with Nat and Ken, this is where we landed:
halt
applied to the relevant codepoint that we want to trim, apply that.hwid
applied to the relevant codepoint and the glyph bounds are identical with/without hwid
(which is a heuristic for “is it the same glyph?”), apply that.The last two are essentially “synthesize the missing halt
” glyphs in fonts that don't have them.
We didn't discuss chws
/vchw
specifically, but they don't seem appropriate because for text-spacing
we want the browser deciding which characters get trimmed, not the font. (Nat was very against using a font feature that makes the decisions about which glyphs to affect, both iirc because the layout engine should maintain control and also because it doesn't work properly across font changes.)
So I think CSS Text 4 should specify the use of halt
, not hwid
or chws
; and we can add some suggested synthesis heuristics (we can discuss further also in #8292) for when the font doesn't support halt
. CC @macnmm @kojiishi
We didn't discuss chws/vchw specifically, but they don't seem appropriate because for text-spacing we want the browser deciding which characters get trimmed, not the font.
I'd agree with that. The fact that this feature uses context detection at the font level means that it'll fail when there are multiple fonts (or multiple font-sizes…).
Also, the documentation for that feature does say this:
Application interface: If a layout engine supports advanced layout for CJK text as described in CLREQ, JLREQ or KLREQ, this feature should not be used.
An engine with support for text-spacing
is exactly that, that's one more point in the direction of not using this feature.
we want the browser deciding which characters get trimmed, not the font.
Fonts can control the kerning amount including disabling for specific glyphs/pairs with the method you described by adjusting halt
, so the chws
isn't much different. For fonts that have chws
but without halt
, chws
is more reliable to know font designers' intentions than glyph bounds.
Also, the documentation for that feature does say this:
It means if the rendering engine/shaping engine applied kerning by halt
or by other methods, chws
shouldn't be enabled. It doesn't mean the rendering engine/shaping engine shouldn't utilize the data in chws
to do the advanced layout.
The CSS Working Group just discussed [css-text-4] `text-spacing` and OpenType halt/vhal/chws/vchw features
, and agreed to the following:
RESOLVED: Use H-ALT when available and need a half-width glyph, continue discussion wrt synthesis
Fonts can control the kerning amount including disabling for specific glyphs/pairs with the method you described by adjusting halt, so the chws isn't much different.
They can, but they aren't expected to. Afaict, HALT should be trimming glyphs unconditionally, whereas for CHWS they're supposed to be context-dependent (that's the point of the feature).
I think it's OK to use CHWS information to synthesize the HALT metrics, but if you just rely on CHWS you won't necessarily get the right behavior, because it might not trim where you need it to (or trim where it's not supposed to).
I think you misunderstood me. Let me try to clarify.
Fonts shoud be able to exclude specific glyphs from being trimmed, when font designers want to do so. They can do it by chws
as you pointed out, but they can also do it by halt
. Some existing fonts already do it. So when you wrote:
They can, but they aren't expected to. Afaict, HALT should be trimming glyphs unconditionally, whereas for CHWS they're supposed to be context-dependent (that's the point of the feature).
and:
we want the browser deciding which characters get trimmed, not the font.
and:
it might not trim where you need it to (or trim where it's not supposed to).
Either with chws
or halt
, fonts can override the browsers' decision. Both chws
and halt
(and all other font features) tell font designers' intentions to the layout engine, and the layout engine should honor them. There's no difference between the features in this regard.
Some existing fonts already do it
Yes, in my fonts I will try to add them.
Either with
chws
orhalt
, fonts can override the browsers' decision
I agree.
Related with #8292 but I think this part is easier to discuss by splitting into a separate issue, so here it is.
When the
text-spacing
property makes some assumption on how glyphs are designed, such as specific parts of the glyph spaces are empty, it's great if font designers can override the behavior when they need.To do this, I'd like to suggest that:
chws
orvchw
, the trimming should be deferred to the feature.chws
norvchw
, if the font hashalt
orvhal
, the trimming should use the feature.Thoughts? /cc @litherum @fantasai @frivoal @MurakamiShinyu @macnmm