Line breaking for Chinese, Japanese, Korean and Thai, in the browser and in WeasyPrint #1052

Closed
opened 2026-10-25 16:29:13 +00:00 by tiagoagueda · 0 comments
Owner

Spun out of #269 (its "From #71" point 4).

Chinese (zh-Hans, zh-Hant) is selected for 0.5, and Japanese, Korean and Thai are in the ordering for later releases. None of these scripts puts spaces between words, so line breaking cannot rely on spaces.

  • Chinese and Japanese: a line may break between almost any two characters. The breaks are governed by kinsoku rules: no closing punctuation such as ,。)」 at the start of a line, and no opening punctuation such as (「 at its end.
  • Korean: uses spaces, but browsers default to breaking inside words (word-break: normal treats Hangul like CJK). Korean text usually wants word-break: keep-all.
  • Thai: has no spaces and no character-level breaks; lines may break only at word boundaries, which needs a dictionary.

What to check

  • Browser: tables, cards, chips and button labels should wrap at legal break points and never overflow. The rules that keep long Latin words from overflowing (overflow-wrap: anywhere, wrap-anywhere) are fine for CJK but wrong for Korean.
  • WeasyPrint (CVs, letters, portfolios): Pango breaks lines itself and handles CJK and Thai via ICU/libthai. Check that the image's Pango build actually has Thai word breaking. Check that hyphens: auto and text-align: justify in the themes do nothing harmful to CJK.

Done when

  • A browser test renders the review page, a table and a CV preview in zh-Hans and th at 320 px wide, with no horizontal scroll and no line starting with closing punctuation.
  • A test renders a CV in zh-Hans and th through WeasyPrint and checks that no line of the text layer starts with closing punctuation, and that Thai breaks only between words.
  • ko uses word-break: keep-all (:lang(ko)).
Spun out of #269 (its "From #71" point 4). Chinese (`zh-Hans`, `zh-Hant`) is selected for 0.5, and Japanese, Korean and Thai are in the ordering for later releases. None of these scripts puts spaces between words, so line breaking cannot rely on spaces. - **Chinese and Japanese:** a line may break between almost any two characters. The breaks are governed by kinsoku rules: no closing punctuation such as `,。)」` at the start of a line, and no opening punctuation such as `(「` at its end. - **Korean:** uses spaces, but browsers default to breaking inside words (`word-break: normal` treats Hangul like CJK). Korean text usually wants `word-break: keep-all`. - **Thai:** has no spaces and no character-level breaks; lines may break only at word boundaries, which needs a dictionary. ## What to check - **Browser:** tables, cards, chips and button labels should wrap at legal break points and never overflow. The rules that keep long Latin words from overflowing (`overflow-wrap: anywhere`, `wrap-anywhere`) are fine for CJK but wrong for Korean. - **WeasyPrint (CVs, letters, portfolios):** Pango breaks lines itself and handles CJK and Thai via ICU/libthai. Check that the image's Pango build actually has Thai word breaking. Check that `hyphens: auto` and `text-align: justify` in the themes do nothing harmful to CJK. ## Done when - A browser test renders the review page, a table and a CV preview in `zh-Hans` and `th` at 320 px wide, with no horizontal scroll and no line starting with closing punctuation. - A test renders a CV in `zh-Hans` and `th` through WeasyPrint and checks that no line of the text layer starts with closing punctuation, and that Thai breaks only between words. - `ko` uses `word-break: keep-all` (`:lang(ko)`).
tiagoagueda added this to the 0.5.0 milestone 2026-10-25 17:04:12 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#1052
No description provided.