Skip to content

tracking is not processed correctly for Japanese #7976

Open

Description

@non-non-vill

Description

In Japanese text, three types of characters are used: kanji, hiragana, and katakana; however, when these characters are mixed, the tracking argument of the text function is not processed correctly.

Examples:

#set text(lang: "ja", font: "Noto Sans CJK JP")
#set text(tracking: 1em)

漢字漢字\  // example of only kanji
ひらがな\ // example of only hiragana
カタカナ\ // example of only katakana
漢ひら字\ // kanji-hiragana mixed
ひ漢字ら\ // kanji-hiragana mixed
漢カタ字\ // kanji-katakana mixed
カ漢字タ\ // kanji-katakana mixed
ひカタら\ // hiragana-katakana mixed
カひらタ\ // hiragana-katakana mixed
Image

As shown in the example above, tracking is applied between characters of the same type (kanji, hiragana, or katakana), but it is not applied between characters of different types.

Operating system

Web app

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Mar 13, 2026
  2. added
    layout
    text
    on Mar 13, 2026
  3. YDX-2147483647 commented on Mar 14, 2026

    @YDX-2147483647
    Contributor

    DeepWiki analysis:

    The problem occurs because different Japanese character types (kanji, hiragana, katakana) are being segmented into separate text runs, preventing tracking from being applied between them.

    I can confirm it by breaking the run manually with *strong*:

    #set text(tracking: 1em)
    - 漢字漢字 // one single run
    - *漢字*漢字 // two runs
    Image

    So the cause is somewhat similar to #7396/#7415, but the problem is more noticeable in Japanese than in Chinese, because Japanese uses multiple scripts while Chinese mostly uses only one script.

  4. YDX-2147483647 commented on Apr 9, 2026

    @YDX-2147483647
    Contributor

    As for this specific example, the desired result can be achieved with linebreak(justify: true).

    #set page(height: auto, width: auto, margin: 15pt)
    #set text(lang: "ja", font: "Noto Sans CJK JP")
    
    #set par(justify: true)
    #set linebreak(justify: true)
    
    #block(width: 7em, stroke: (x: green + 0.5pt))[
      漢字漢字\  // example of only kanji
      ひらがな\ // example of only hiragana
      カタカナ\ // example of only katakana
      漢ひら字\ // kanji-hiragana mixed
      ひ漢字ら\ // kanji-hiragana mixed
      漢カタ字\ // kanji-katakana mixed
      カ漢字タ\ // kanji-katakana mixed
      ひカタら\ // hiragana-katakana mixed
      カひらタ\ // hiragana-katakana mixed
      *漢字*漢字\ // strong(han)-han
    ]
    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglayouttext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions