Skip to content

[css-fonts-4] font-kerning:normal and CJK fonts with kerning pairs for fullwidth not well defined #6723

Open

Description

@macnmm

Normal kerning for CJK fonts that support the ‘kern’ feature should only apply the feature on proportional glyphs. By default this means excluding the fullwidth CJK glyphs and only kerning the proportional Latin glyphs.
If kerning the CJK fullwidth glyphs you must also apply ‘palt’ (‘vpal’ in vertical) or the kerning amounts will be incorrect. This kerning should be optional and not the default.

Activity

  1. xfq commented on Oct 12, 2021

    @xfq
    Member
  2. added
    i18n-jlreqJapanese language enablement
    i18n-trackerGroup bringing to attention of Internationalization, or tracked by i18n but not needing response.
    on Oct 12, 2021
  3. svgeesus commented on Oct 12, 2021

    @svgeesus
    Collaborator

    Regarding optionality and the default: CSS Fonts 4 does not specify that kerning is on by default. The initial value is 'auto':

    auto
    Specifies that kerning is applied at the discretion of the user agent
    When set to auto, user agents can determine whether to apply kerning or not based on a number of factors: text size, script, or other factors that influence text processing speed.

    However it does claim that:

    When rendering with OpenType fonts, the [OPENTYPE] specification suggests that kerning be enabled by default.

    I don't find that suggestion in the definition of the kern table or the GPOS table and find the opposite in the OpenType overview:

    Many features expose optional capabilities that authors and typographers may choose to use at their discretion; for example, small cap forms, or kerning.

    So I wonder where that claim came from and whether we should remove it.

    Regarding the specifics of kerning and CJK, I wonder if we can expand the mention of "script" quoted above to give the specific details that fixed-width glyphs should not be kerned. I don't find the 'palt' or 'vpal' tables in the OpenType specification, nor in the TrueType specification. Where are they defined?

  4. svgeesus commented on Oct 12, 2021

    @svgeesus
    Collaborator

    Oh I see they are OpenType features, not tables: 'palt' and 'vpal'

  5. macnmm commented on Oct 13, 2021

    @macnmm
    Author

    Agree that 'auto' is currently confusing and those UAs that apply the 'kern' feature when kerning is 'auto' will run into the CJK issue above.

  6. frivoal commented on Jan 27, 2023

    @frivoal
    Collaborator
  7. fantasai commented on Feb 1, 2023

    @fantasai
    Collaborator

    Discussing with @MurakamiShinyu, we outlined 5 possible things that an author might want to do:

    1. no kerning
    2. kern non-CJK† only
    3. apply palt/vpal and kern everything
    4. apply palt/vpal and kern non-CJK
    5. apply palt/vpal and kern nothing

    Of these 5, the first 3 seem to be clearly needed; the last two, we're not sure. Either way, the spec should clarify that kerning CJK requires applying palt/vpal as well.

    A question raised was whether palt/vpal should be applied via font-variant-east-asian where we already have the somewhat-related proportional-width keyword. But font-variant is fundamentally about alternate glyphs whereas palt/vpal is about spacing, so font-kerning is probably a better place to control it.

    Possible syntax for these options:

    1. font-kerning: none
    2. font-kerning: normal
    3. font-kerning: all (new keyword)
    4. Unclear if we need this (not easy to work around if needed)
    5. Unclear if we need this (can use font-feature-settings if needed‡)

    It might be useful to hear from @macnmm and others if options 4 or 5 are needed.

    † The appropriate division here is probably East Asian Wide vs others.
    ‡ The naive way to do this would be font-kerning: none; font-feature-settings: "palt", but this doesn't handle writing modes correctly, so the correct way to do it would be font-kerning: all; font-feature-settings: "kern" off, "vkrn" off.

  8. macnmm commented on Feb 2, 2023

    @macnmm
    Author

    I don't think option 4 is common. Option 5 is common only because most CJK fonts lack kerning pairs so palt/vpal is their only option for proportional layout and they may have documents that do not set kerning on or have it set to 0. However, option 5 would also turn off kerning for non-CJK, so perhaps it is not common because of that.

  9. MurakamiShinyu commented on Feb 4, 2023

    @MurakamiShinyu

    I tweeted about extending the font-kerning property values for CJK proportional spacing and kerning,

    and got many supportive reactions for the new value all (= 3. apply palt/vpal and kern everything).

    Options 4 and 5 do not appear to be needed. I got a reply about it:

    For "loose kerning" purpose, it will be better to use letter-spacing together with font-kerning: all, e.g.:

    .loose-kerning {
      font-kerning: all; /* 'palt' on, 'kern' on */
      letter-spacing: 0.05em;
    }
  10. kojiishi commented on Feb 7, 2023

    @kojiishi
    Contributor

    How about sending this issue to OpenType, so that they can improve the definition?

    Given existing fonts are incompatible today, they can improve the definition so that future fonts being more compatible. They could also define features that can make both types of fonts happy, and CSS can define a property to control the features.

    With the current shaping engine APIs, it's not easy for browsers to apply features only if glyphs are fullwidth. Resolving this issue by the cooperation with OpenType and shaping engines can also ensure browsers match the native applications.

    /cc @litherum @jfkthame

  11. macnmm commented on Feb 8, 2023

    @macnmm
    Author

    How about sending this issue to OpenType, so that they can improve the definition?

    Given existing fonts are incompatible today, they can improve the definition so that future fonts being more compatible. They could also define features that can make both types of fonts happy, and CSS can define a property to control the features.

    With the current shaping engine APIs, it's not easy for browsers to apply features only if glyphs are fullwidth. Resolving this issue by the cooperation with OpenType and shaping engines can also ensure browsers match the native applications.

    /cc @litherum @jfkthame

    I am not aware of font incompatibilities -- when the font has 'kern' values set on fullwidth glyphs, they must necessarily start from the 'palt' widths, otherwise they would have too many pairs and not achieve proportional typography, which is the point of kerning.

    As far as when to apply proportional features, this is kind of the legacy of CJK fonts mixing proportional Latin with monospaced CJK in one font by default, but offering non-default widths and kerning as an option. Not sure a new OTF feature would solve this differently...

  12. MurakamiShinyu commented on Mar 4, 2023

    @MurakamiShinyu

    @kojiishi:

    With the current shaping engine APIs, it's not easy for browsers to apply features only if glyphs are fullwidth.

    Does this mean that it is difficult to not apply 'kern' only if glyphs are fullwidth?

    In @fantasai's suggestion, “2. kern non-CJK† only” does not require checking if glyphs are really fullwidth, because “† The appropriate division here is probably East Asian Wide vs others.”

    This better default font-kerning behavior “kern non-CJK only” is already implemented in Firefox (effective when font-kerning: auto. Their font-kerning: normal corresponds to font-kerning: all in the new proposal here).

    I think this default “kern non-CJK only” is very nice for most CJK fonts. However, this may be not good for some not very common CJK fonts which have proportional CJK glyphs by default (not by 'palt') and have kerning feature. I am not aware of such Japanese fonts, but it would be possible. (MS PGothic and MS PMincho are well known examples of Japanese proportional fonts, but they have no kerning feature.)

    On Korean font kerning, Requirements for Hangul Text Layout and Typography - §2.4 Kerning for Hangul Fonts is very interesting.

    AG Ahnsangsoo 2012 is a proportional Hangul font family with kerning feature.

    Kerning should be enabled for CJK text by default for such fonts. So I think the normal font-kerning behavior should be corrected to:

    • If the font has palt/vpal feature, kern non-CJK only, otherwise kern everything.

    Is this difficult to implement?

  13. kojiishi commented on Apr 14, 2023

    @kojiishi
    Contributor

    There is a long Japanese thread at public-i18n-japanese, still without consensus.

    I replied to @MurakamiShinyu's questions above in the Japanese thread.

  14. 17 remaining items

  15. svgeesus commented on Oct 16, 2026

    @svgeesus
    Collaborator
    • font implementing palt + kern, without apkn: activate palt and kern together.

    • font implementing apkn: activate palt and apkn together. kern remains active as usual, since in such a font it carries only pairs for glyphs that are proportional by default.

    I assume that this is for horizontal typographic modes (and for sideways typesetting in vertical typographic modes).

    For for upright typesetting in vertical typographic modes, without apkn, would palt + vkrn be used?

  16. taroyamamoto-451 commented on Oct 17, 2026

    @taroyamamoto-451

    Regarding the application of proportional metrics and pair kerning to glyphs representing Japanese characters, essentially the same principles apply to the vertical writing mode as to the horizontal writing mode.

    In horizontal text, the 'palt' feature is used to make glyphs representing Japanese characters (primarily kana glyphs) behave as if they had proportional widths and sidebearings, while 'apkn' or 'kern' is used to apply kerning to specific pairs of these glyphs. The 'palt' feature must not be applied by default. The 'apkn' feature must not be applied unless the 'palt' feature has been explicitly applied. The 'kern' feature must not be applied to Japanese glyphs unless the 'palt' feature has been explicitly applied. The 'apkn' feature must not be applied by default. If the 'apkn' feature is absent, the 'kern' feature must not be applied to Japanese glyphs unless the 'palt' feature has been explicitly applied.

    In vertical text, the 'vpal' feature is used to make glyphs representing Japanese characters (primarily kana glyphs) behave as if they had proportional widths and sidebearings, while 'vapk' or 'vkrn' is used to apply kerning to specific pairs of these glyphs. The 'vpal' feature must not be applied by default. The 'vapk' feature must not be applied unless the 'vpal' feature has been explicitly applied. The 'vkrn' feature must not be applied to Japanese glyphs unless the 'vpal' feature has been explicitly applied. The 'vapk' feature must not be applied by default. If the 'vapk' feature is absent, the 'vkrn' feature must not be applied to Japanese glyphs unless the 'vpal' feature has been explicitly applied.

    I think these principles should apply, but please point out any errors you find.

  17. taroyamamoto-451 commented on Oct 17, 2026

    @taroyamamoto-451

    In addition, as mentioned above, if 'palt' and 'kern' are present but 'apkn' is absent, 'kern' must not be applied unless 'palt' is applied to Japanese glyphs. However, once 'palt' is applied, 'kern' may also be applied. If 'kern' is applied, it must be applied to all glyph pairs for which kerning is defined, including pairs containing Japanese or non-Japanese glyphs that are not covered by 'palt'

    This is important because not all Japanese glyphs in glyph pairs for which kerning is defined need to be made proportional using 'palt', although most of them typically do. The same principle applies to 'apkn' and 'palt'.

  18. moved this to Tuesday Internationalization session topics in CSSWG agenda TPAC 2026on Oct 21, 2026
  19. svgeesus commented on Oct 22, 2026

    @svgeesus
    Collaborator

    When kerning is explicitly requested:

    * font implementing `palt` + `kern`, without `apkn`: activate `palt` and `kern` together.
    

    OpenType says

    If a font supports this feature and also supports kerning, it is recommended that kerning for glyphs affected by this feature be implemented using the 'apkn' feature and not the 'kern' feature. (The 'kern' feature should still be used for glyphs that have proportional widths by default.)

    I have therefore made palt + kern a SHOULD NOT, unless apkn is not available. I also scoped it to only those gyphs with Proportional Alternate Widths, to make it clear that kern should be applied to the other glyphs.

  20. svgeesus commented on Oct 22, 2026

    @svgeesus
    Collaborator

    Please take a look at the new wording regarding apkn and palt:

    https://www.w3.org/TR/css-fonts-4/#font-kerning-prop

  21. tats-u commented on Oct 22, 2026

    @tats-u

    What if a font vendor cannot think of even a single pair of glyphs for which apkn should be set?

  22. svgeesus commented on Oct 22, 2026

    @svgeesus
    Collaborator

    What if a font vendor cannot think of even a single pair of glyphs for which apkn should be set?

    In that case, apkn would be empty, presumably not included in the font, and thus kern would be used.

  23. taroyamamoto-451 commented on Oct 23, 2026

    @taroyamamoto-451

    svgeesus wrote:

    I have therefore made palt + kern a SHOULD NOT, unless apkn is not available. I also scoped it to only those gyphs with Proportional Alternate Widths, to make it clear that kern should be applied to the other glyphs.

    I think you mean:
    I have therefore made palt + kern a SHOULD NOT, if apkn is available.

    I also scoped it to only those gyphs with Proportional Alternate Widths, to make it clear that kern should be applied to the other glyphs.

    I don't understand this well.
    When applied to Japanese glyphs, either 'kern' or 'apkn' may cover glyphs that are not covered by 'palt' (Proportional Alternate Widths).

  24. tats-u commented on Oct 23, 2026

    @tats-u

    I wonder if this is technically possible:

    kern should not be applied to pairs where at least one of the glyphs can have palt applied when palt is disabled (, as long as apkn is missing).

  25. svgeesus commented on Oct 23, 2026

    @svgeesus
    Collaborator

    Thanks for the review of these sections. I guess the wording from Opentype that I quoted above is aimed at font developers (use this, not that), not so much at developers of text rendering software (if it has this, do this thing; if it has that, do another; if it has both then ...)

    Could you suggest better wording for the current text;

    For these glyphs, the kern feature is not used; instead, the Kerning for Alternate Proportional Widths must be applied, using the apkn feature.

  26. svgeesus commented on Oct 23, 2026

    @svgeesus
    Collaborator

    For those who will attend TPAC, either in person or remotely, this issue is on the agenda for the Tuesday morning joint meeting between CSS WG and I18 Core WG. Members of JLReq Task Force would also be most welcome at that meeting.

    I'm trying to get this specification in the best shape before that meeting, to aid discussion as the text is further clarified and refined.

  27. tats-u commented on Oct 23, 2026

    @tats-u

    I feel like my understanding of apkn and palt (mainly their differences) is a bit lacking. The activation conditions for both seem to be the same, so I'm suspecting that one of them might not even have a reason to exist. I modified my most recent comment slightly: #6723 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

css-fonts-4Current Worki18n-jlreqJapanese language enablementi18n-trackerGroup bringing to attention of Internationalization, or tracked by i18n but not needing response.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions