You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-fonts] Improve implementation guidance for font-kerning #7958
The CSS Fonts spec says that when kerning is enabled (i.e. with font-kerning: normal, or with the initial auto value "at the discretion of the user agent"), the OpenType 'kern' (horizontal) or 'vkrn' (vertical) feature should be applied.
Current browser engines appear to have overlooked this, and by default apply 'kern' but not 'palt' in the reporter's testcase.
I'd suggest it would be helpful to mention these associated features in the CSS Fonts description of how kerning is implemented when using OpenType fonts.
Reacted by Mike Bremford, Ln-north and Shinyu Murakami
In addition, the reporter in https://bugzilla.mozilla.org/show_bug.cgi?id=1797431 points out that for CJK text, kerning should not be used by default. The testcase at https://tama-san.com/otf_test/ indicates that current browsers (I tried Firefox, Safari and Chrome) all apply kerning by default (i.e. when font-kerning: auto is in effect) to the CJK characters, which is not desired.
The spec currently leaves the behavior of auto to "the discretion of the user agent". We should note that while the UA may use its "discretion" for content such as Latin (e.g. to optimize performance, as implied by the comments in the spec), for CJK scripts, kerning SHOULD NOT (or MUST NOT?) be applied automatically, but only when explicitly requested by font-kerning: normal.
Apologies for asking some basic questions. The spec says
'normal' Specifies that kerning is applied
So for CJK, does normal mean 'not-normal'?
You could say that, yes. (But remember that the initial value of font-kerning is not normal but auto, which gives the browser scope to "do the right thing" automatically as a default.)
Or does it mean that kerning applies only if the font supports it?
Well, that's always part of the picture -- yes, a feature like kerning depends on font support. If the font doesn't define any kerning, then the font-kerning property will have no effect.
Is it possible for the browser to kern CJK fonts when no such information is included in the font?
In theory (for any font, not just CJK), but I'm not aware of any browser engine that does so. (I believe some desktop publishing software such as InDesign may do things like that.)
(Is there a general case here where we need to be more careful about script-specific assumptions before using values like 'normal'?)
Maybe. Though I tend to think of things like font-kerning as being quite script-agnostic. The value normal doesn't directly mean "do what is normal (for any given script or context)", but rather "use what the font designer specified". (Perhaps it should've been named always instead? But then, it wouldn't really mean "always", it'd mean "always, if the font provides it".)
Based on the bug report and the "default" output (the first line of text) shown in there after your patch, am I correct that the intention for font-kerning:auto will be:
kerning is not applied between two glyphs that are in a CJK script
kerning is applied between two glyphs that are latin, regardless of language
I'm unclear what happens with neutrals, eg ティ(0)ティ(0)WA - it to me that it shouldn't be applied between the kana but should apply elsewhere? Including between ")" and "テ" for example?
My mental model is that text is segmented into script runs, with "neutrals" adopting the script of their context. (Some hand-waving about behavior of neutrals at boundaries....) At the point where the font shaping engine performs kerning of a given piece of text, some decision must have been made regarding script, because it is an input to the shaping process. Then it's as simple as letting the font-kerning:auto value behave according to the resolved script of the text run being shaped.
So in your example, I'd expect the parentheses to be considered part of the Japanese text run, where no kerning is to be applied.
This was once discussed in JLTF, and IIUC we consider this part of the OpenType spec is controversial, may have a negative impact for CJK. I think what we should do is to file an issue to OpenType.
/cc @kidayasuo@r12a How about discussing this in JLTF again?
I am a font engineer in font vendor. So I understand the difficulty in changing font files that have already been released.
It certainly seems to me that we need Opentype's cooperation on the issues you present.
(For example, meta information such as glyph groups could be added)
We understand that there is a need to cooperate with the CSS WG and JLTF as well in providing CSS users means to already released fonts, and in using the information on Opentype that has been formulated.
One of the issues seems to be the ability to specify glyph groups to which the Opentype Feature is applied. If so, I think it would be acceptable to follow the current Opentype behavior as the default behavior.
I look forward to the results of the discussion in the JLTF.
kerning is not applied between two glyphs that are in a CJK script
It seems to me from reading the above that some font designers do apply kerning to their CJK fonts, and presumably there should be a way for the content author to enable that as a default if the font kerns by default. So turning off any kerning for CJK characters seems a bit draconian. As for where to apply kerning and where not, doesn't that fall out of which font is being used for a range of characters, rather than which characters are being used? If so, perhaps normal (and/or auto?) should perhaps simply apply what the font designer intended. Doesn't that circumvent the issues surrounding when to apply kerning and when not? (Of course, one may want the ability to also turn on non-default kerning, if it's available (although perhaps a new value is needed for font-kerning to do that?), or to turn off kerning, but those seem like straightforward choices.)
Activity
jfkthame commentedon Oct 27, 2022
In addition, the reporter in https://bugzilla.mozilla.org/show_bug.cgi?id=1797431 points out that for CJK text, kerning should not be used by default. The testcase at https://tama-san.com/otf_test/ indicates that current browsers (I tried Firefox, Safari and Chrome) all apply kerning by default (i.e. when
font-kerning: autois in effect) to the CJK characters, which is not desired.The spec currently leaves the behavior of
autoto "the discretion of the user agent". We should note that while the UA may use its "discretion" for content such as Latin (e.g. to optimize performance, as implied by the comments in the spec), for CJK scripts, kerning SHOULD NOT (or MUST NOT?) be applied automatically, but only when explicitly requested byfont-kerning: normal.r12a commentedon Oct 28, 2022
Apologies for asking some basic questions. The spec says
So for CJK, does
normalmean 'not-normal'? Or does it mean that kerning applies only if the font supports it?Is it possible for the browser to kern CJK fonts when no such information is included in the font?
(Is there a general case here where we need to be more careful about script-specific assumptions before using values like 'normal'?)
jfkthame commentedon Oct 28, 2022
You could say that, yes. (But remember that the initial value of
font-kerningis notnormalbutauto, which gives the browser scope to "do the right thing" automatically as a default.)Well, that's always part of the picture -- yes, a feature like kerning depends on font support. If the font doesn't define any kerning, then the
font-kerningproperty will have no effect.In theory (for any font, not just CJK), but I'm not aware of any browser engine that does so. (I believe some desktop publishing software such as InDesign may do things like that.)
Maybe. Though I tend to think of things like
font-kerningas being quite script-agnostic. The valuenormaldoesn't directly mean "do what is normal (for any given script or context)", but rather "use what the font designer specified". (Perhaps it should've been namedalwaysinstead? But then, it wouldn't really mean "always", it'd mean "always, if the font provides it".)faceless2 commentedon Oct 28, 2022
Based on the bug report and the "default" output (the first line of text) shown in there after your patch, am I correct that the intention for
font-kerning:autowill be:ティ(0)ティ(0)WA- it to me that it shouldn't be applied between the kana but should apply elsewhere? Including between ")" and "テ" for example?jfkthame commentedon Oct 28, 2022
My mental model is that text is segmented into script runs, with "neutrals" adopting the script of their context. (Some hand-waving about behavior of neutrals at boundaries....) At the point where the font shaping engine performs kerning of a given piece of text, some decision must have been made regarding script, because it is an input to the shaping process. Then it's as simple as letting the
font-kerning:autovalue behave according to the resolved script of the text run being shaped.So in your example, I'd expect the parentheses to be considered part of the Japanese text run, where no kerning is to be applied.
kojiishi commentedon Nov 2, 2022
This was once discussed in JLTF, and IIUC we consider this part of the OpenType spec is controversial, may have a negative impact for CJK. I think what we should do is to file an issue to OpenType.
/cc @kidayasuo @r12a How about discussing this in JLTF again?
kojiishi commentedon Nov 17, 2022
I noticed #6723 is about the same topic? I'm sending both to JLTF soon.
ln-north commentedon Nov 28, 2022
I'm a reporter on Bugzilla#1797431. Thank you for your cooperation.
Seems like it. This isssue seems a bit more specific.
If possible, I would like to know a way to catch up on what you discuss (or outline) at JLTF and what you report to Opentype.
kojiishi commentedon Nov 28, 2022
I'll get back to here with the results. This seems complicated.
kernonly to glyphs that are not CJK, and glyphs that are CJK but are not fullwidth, even iffont-kerning: normal.kernto all glyphs.Both sides are already shipping fonts based on their assumptions.
ln-north commentedon Nov 29, 2022
I am a font engineer in font vendor. So I understand the difficulty in changing font files that have already been released.
It certainly seems to me that we need Opentype's cooperation on the issues you present.
(For example, meta information such as glyph groups could be added)
We understand that there is a need to cooperate with the CSS WG and JLTF as well in providing CSS users means to already released fonts, and in using the information on Opentype that has been formulated.
One of the issues seems to be the ability to specify glyph groups to which the Opentype Feature is applied. If so, I think it would be acceptable to follow the current Opentype behavior as the default behavior.
I look forward to the results of the discussion in the JLTF.
r12a commentedon Nov 29, 2022
It seems to me from reading the above that some font designers do apply kerning to their CJK fonts, and presumably there should be a way for the content author to enable that as a default if the font kerns by default. So turning off any kerning for CJK characters seems a bit draconian. As for where to apply kerning and where not, doesn't that fall out of which font is being used for a range of characters, rather than which characters are being used? If so, perhaps
normal(and/orauto?) should perhaps simply apply what the font designer intended. Doesn't that circumvent the issues surrounding when to apply kerning and when not? (Of course, one may want the ability to also turn on non-default kerning, if it's available (although perhaps a new value is needed for font-kerning to do that?), or to turn off kerning, but those seem like straightforward choices.)Sorry if i'm barking up the wrong tree.
MurakamiShinyu commentedon Feb 4, 2023
Instead of the 'not-normal'
normal, oralways, the new keywordallis proposed:In this proposal,
font-kerning: normalmeans "kern non-CJK only" andfont-kerning: allmeans "apply palt/vpal and kern everything".Perhaps "kern non-CJK only" should be modified for proportional-only CJK fonts.
Let's continue the discussion in #6723.
ln-north commentedon Feb 7, 2023
This proposal satisfies all my requirements.
I will continue to watch that discussion.
Thank you for your contribution, @MurakamiShinyu.