Skip to content

Natural phrase-based line breaking for CJK and Thai (like word-break: auto-phrase) #8097

Open

Description

@3w36zj6

Description

In English and many similar languages, natural line breaking is easily supported due to the use of spaces to separate words. However, in languages such as Japanese, Chinese, and Thai, words are not separated by spaces. Therefore, achieving natural, phrase-based automatic line breaking is known to be a complex problem that typically requires morphological analysis or dictionary-based approaches.

In Chromium-based web browsers, the CSS property word-break: auto-phrase; has been implemented to support language-aware, phrase-based line wrapping1. Under the hood, this is powered by BudouX, which is a lightweight machine learning model by Google. Since utilizing a pre-trained model for this purpose is highly efficient and lightweight, it would be extremely beneficial if Typst natively supported such natural phrase-based line breaking.

Use Case

This feature benefits design-oriented typesetting in languages like Japanese, Chinese, and Thai.

Footnotes

  1. https://developer.mozilla.org/en-US/docs/Web/CSS/word-break#auto-phrase ↩

Activity

  1. added
    feature request
    on Apr 12, 2026
  2. added
    text
    cjk
    on Apr 12, 2026
  3. YDX-2147483647 commented on May 24, 2026

    @YDX-2147483647
    Contributor

    Note that for Chinese, phrase-based line breaking is quite rare. It only exists in elementary textbooks that teach Chinese as a second language.
    Therefore, this feature should be disabled by default for lang: "zh" when it’s implemented.

    More discussions (in Chinese) can be found at https://www.thetype.com/2018/01/14017/.

    Edit: According to word-break CSS property - CSS | MDN (already shared above), CSS word-break: auto-phrase is supported only by Blink/Chromium, and has effect only if lang="ja".

  4. 3w36zj6 commented on May 28, 2026

    @3w36zj6
    ContributorAuthor

    This word-break: auto-phrase equivalent function is often vulnerable to proper nouns, so I believe users should need to explicitly enable it for all languages.

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

    cjkfeature requesttext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions