Skip to content

Fix Thai justified text breaking before spaces and trailing punctuations - #9024

Open
haminic wants to merge 1 commit into
typst:mainfrom
haminic:thai-justified-linebreak
Open

haminic wants to merge 1 commit into
typst:mainfrom
haminic:thai-justified-linebreak

Conversation

@haminic

@haminic haminic commented Oct 28, 2026

Copy link
Copy Markdown

Fixes #5543, fixes #7646.

Upgrades icu_segmenter to 2.4.0. In previous versions, there was a bug in which languages like Thai, Khmer, Lao, and Burmese can have breakpoints before spaces and punctuations, causing justified text to sometimes throw lone spaces or punctuations at the start of a new line. This was fixed in unicode-org/icu4x#8574.

Also adds regression tests in issue-5543-linebreak-thai-justified-space and issue-7646-linebreak-thai-justified-punctuations.

Fixes typst#5543 and typst#7646 where justified text for languages like Thai
break before spaces and punctuation.
@admannon

Copy link
Copy Markdown

Following the #9057 discussion and unicode-org/icu4x#8381, could we add a layout regression test for a Thai word joined by U+2060 and followed by more Thai text? The classic segmenter keeps the boundary after the joined word, while the neo segmenter does not:

--- thai-word-joiner paged ---
#set page(width: 50pt)
#set text(lang: "th")
ประกัน\u{2060}ภัยดี

Expected: a break after ภัย.

LineSegmenter::new_lstm (this PR) returns breakpoints ["ประกัน\u2060ภัย", "ดี"]; the neo segmenter returns one segment ["ประกัน\u2060ภัยดี"], so the line overflows.

This test would lock the classic behavior now and give #9057 a reference once the neo run splitting is fixed upstream (unicode-org/icu4x#8381).

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

Labels

waiting-on-review This PR is waiting to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forbid breaking before closing single and double quotes in Thai text Wrong spacing for Thai words after a line break.

3 participants