Repository navigation
Update the line segmenter to Unicode 18, and updated outdated notes and tests - #9057
Draft
YDX-2147483647 wants to merge 1 commit into
Draft
YDX-2147483647 wants to merge 1 commit into
YDX-2147483647 wants to merge 1 commit into
Conversation
YDX-2147483647
marked this pull request as draft
November 10, 2026 12:07
YDX-2147483647
force-pushed
the
icu4xup
branch
from
November 10, 2026 16:17
21fb1f0 to
412b83e
Compare
YDX-2147483647
force-pushed
the
icu4xup
branch
from
November 10, 2026 16:31
412b83e to
88469c8
Compare
…nd tests The previous line segmenter was Unicode 15.1 with a CJ patch. Co-authored-by: Peerakarn Junmunee <[email protected]> Co-authored-by: Manish Goregaokar <[email protected]>
YDX-2147483647
force-pushed
the
icu4xup
branch
from
November 10, 2026 16:42
88469c8 to
656b5b5
Compare
1 task done
Minimal repro: WJ-joined Thai word becomes unbreakable with the neo segmenterICU4X 2.4 (comparing this PR's setup vs #set page(width: 50pt)
#set text(lang: "th")
ประกัน\u{2060}ภัยดี
With Simple Could we add a regression test for this, and consider classic/#9024 as the base until ICU4X resolves the neo run-splitting (unicode-org/icu4x#8381)? |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Typst uses the icu_segmenter library to determine line break opportunities. This library is part of the ICU4X project developed by the Unicode Consortium, and it implements the Unicode Line Breaking Algorithm (UAX
#14).At present, Typst uses the classic line segmenter targeting Unicode 15.1 provided by ICU4X 2.2 with a CJ patch. In some cases, the UAX
#14algorithm in Unicode 15.1 does not give ideal results.This PR replaces that with the neo line segmenter targeting Unicode 18.0 provided by ICU4X 2.4, remove the now-unneeded CJ patch, and update outdated comments in codes and tests. The new UAX
#14algorithm fixes a few bugs. See the test cases added tolinebreak.rsfor the details.Closes #9002.
Resolves #6400, resolves #6774, resolves #8193.
Note that the neo line segmenter is still behind the
unstablefeature. https://github.com/Manishearth, a core contributor to ICU4X, once said on 2026-10-27 that it will be stabilized “hopefully in the next release”.I am publishing this draft PR to record the bugs that Unicode 18 can fix. However, I suggest not merging this PR until ICU4X releases the next version.
Technical details
Many changes in this PR were covered in v0.15.1...admannon:typst:bump-icu-2.3 and Update ICU4X to 2.4, remove now-unneeded CJ_SEGMENTER #9003. Nonetheless, there is no need for reviewers to specifically inspect those two branches.
The ICU4X line segmenters and Unicode UAX
#14are versioned separately. There are bugs that can be fixed by upgrading ICU4X without switching to the neo line segmenter. Fix Thai justified text breaking before spaces and trailing punctuations #9024 is doing that. I suggest we merge that PR first.icu_collator in Cargo.lock is also updated from 2.3 to 2.4, as a side effect of updating icu_segmenter and icu_properties to 2.4.
It seems that the only direct usage of icu_collator in repo is to generate docs, so I guess updating icu_collator is okay. By the way, the hayagriva repo specifies icu_collator 2.2 at present.
UAX
#14never has specialized rules for URLs, but the support for URLs has indeed improved a little. See the additional info inhttps://should not be broke into three lines #9056.This PR shares some codes with Improve the line breaking algorithm for links #9085. Improve the line breaking algorithm for links #9085 is expected to be merged first. I'll resolve conflicts in this PR if necessary.
TODO
Does anyone know Hebrew? Could you take a look at the added test cases for Hebrew? Please see Problem with em spaces (or en) with justified paragraphs. #8193 (comment) for the specific questions. (no Rust knowledge is required)
Wait for the next release of ICU4X.
After this PR is merged, someone should remove the CJ patch from typst-assets and archive https://github.com/typst/icu4x.