Skip to content

ICU4X 2.4 is released with Unicode 17.0 and 18.0 data #9002

Open

Description

@Manishearth

/// The line break segmenter for Chinese/Japanese text.
///
/// This is generated by manually overriding the line break properties for curly
/// quotes `U+201C` and `U+201D` from `QU` (`Quotation`) to `OP`
/// (`OpenPunctuation`) and `CP` (`CloseParenthesis`), respectively.
///
/// This can be combined with [`SEGMENTER`] once ICU4X updates the line
/// segmenter to Unicode 17.0. This will also allow us to remove the `serde`
/// feature from the dependency.
static CJ_SEGMENTER: LazyLock<LineSegmenter> = LazyLock::new(|| {
let blob = typst_assets::icu::ICU_CJ_SEGMENT;
let cj_provider = BlobDataProvider::try_new_from_static_blob(blob).unwrap();
LineSegmenter::try_new_for_non_complex_scripts_with_buffer_provider(
&cj_provider,
LineBreakOptions::default(),
)
.unwrap()
});

This code should be unnecessary now.

Note that ICU4X supports both Unicode 17 and 18 data here, you can get the 18 data by calling the unstable new_neo constructors (https://docs.rs/icu_segmenter/latest/icu_segmenter/struct.LineSegmenter.html) which use the more modern data format. Those constructors will be the ones that continue to get updated.

Activity

  1. Manishearth commented on Oct 24, 2026

    @Manishearth
    Author
  2. YDX-2147483647 commented on Oct 25, 2026

    @YDX-2147483647
    Contributor

    About icu4x versions

    Relates-to: #8406
    That PR updated icu4x from 1.4 to 2.2, and kept the CJ segmenter intentionally in typst/typst-assets#20.

    Update:
    I've provided more details in #9003 (comment).
    In short, the new icu4x APIs (new_17_* for Unicode 17.0 and new_neo_* for Unicode 18.0) do eliminate the need of a CJ segmenter patch, but they are unstable (behind the unstable feature flag) and don't support complex scripts (e.g., Thai) yet.
    Therefore, I suggest we stay with the old icu4x API (new_{auto,lstm,…} for Unicode 15.1) and keep the CJ patch, until icu4x adds support for complex scripts to the new API in the future.

    Update 2:
    See Peerakarn Junmunee's comment below. It is possible to combine the new APIs with the classic LSTM data.
    v0.15.1...admannon:typst:bump-icu-2.3

    Advantages of newer icu4x segmenters

    I suggest we include these as test cases when upgrading icu4x.

    In the descriptions below, Unicode 15 = LineSegmenter::new_auto, Unicode 17 = LineSegmenter::new_17_for_non_complex_scripts, and Unicode 18 = LineSegmenter::new_neo_for_non_complex_scripts.

    Details

    In Zellkulturschalen und -flaschen, the line should not break after the hanging/suspended hyphen

    • Unicode 15 gives the wrong result:
      |Zellkulturschalen |und |-|flaschen|
    • Unicode 17 and 18 give the correct result:
      |Zellkulturschalen |und |-flaschen|

    Reported by laalsaas on 2026-11-09 on the forum, tested with icu4x v2.4.0.

    This was an intended change to the Unicode Line Breaking Algorithm. See Unicode 16 modifications to UAX #14: Added LB20a to prevent line breaks after word-initial hyphens.

    In 《女神·天狗》, the line should not break before the interpunct (U+00B7 ·)

    • Unicode 15 and 17 give the wrong result:
      |《女|神|·|天|狗》|
    • Unicode 18 gives the correct result:
      |《女|神·|天|狗》|

    Reported in #6774 on 2025-08-17, tested with icu4x v2.4.0.
    This was also intended. See unicode-org/icu4x#7500 (comment).

    No-break spaces after hyphens should prevent line breaks

    For example, Test test~--~test (typst markup):

    • Unicode 15 and 17 give the wrong result:
      |Test |test –| test|
    • Unicode 18 gives the correct result:
      |Test |test – test|

    Reported in #6400 on 2025-06-07, tested with icu4x v2.4.0.
    This was also intended. See Unicode 18 modifications to UAX #14: Changed rule LB12a to disallow a break between BA and GL, e.g., between EN DASH and NO-BREAK SPACE.

    Em spaces in Hebrew should not prevent line breaks

    For example:

     ישבה על מדוכה זו ברבות מישיבותיה בשנים תשנ"ד–תשס"ה ופעלה נמרצות לשיפור הכללים, להשלמתם ולעדכונם. נוסף על כך העמידה הוועדה כללים חדשים רבים –

    • Unicode 15 gives the wrong result:
      | |ישבה על מדוכה זו ברבות מישיבותיה בשנים תשנ"ד–תשס"ה ופעלה נמרצות לשיפור הכללים, |להשלמתם ולעדכונם. |נוסף על כך העמידה הוועדה כללים חדשים רבים –|

    • Unicode 17 and 18 gives the correct result:
      | |ישבה |על |מדוכה |זו |ברבות |מישיבותיה |בשנים |תשנ"ד–|תשס"ה |ופעלה |נמרצות |לשיפור |הכללים, |להשלמתם |ולעדכונם. |נוסף |על |כך |העמידה |הוועדה |כללים |חדשים |רבים –|

    Reported in #8193 on 2026-11-10, tested with icu4x v2.4.0.
    This was also intended. See Unicode 16 modifications to UAX #14: Modified LB21a to restrict its effect to hyphens that separate Hebrew from non-Hebrew.

    The U+2060 WORD JOINER among Thai texts should be respected.

    I don't know the details… Please see the comments below.

  3. added
    dependencies
    i18n
    on Oct 25, 2026
  4. admannon commented on Oct 30, 2026

    @admannon

    FWIW, I've already tested Thai with the new ICU4X neo segmenters.

    My testing started with Typst #8413, then led to ICU4X unicode-org/icu4x#8243 (WORD JOINER handling), which is now referenced by ICU4X unicode-org/icu4x#7962. I also tried bumping Typst v0.15.1 to ICU4X 2.3 (https://github.com/admannon/typst/tree/bump-icu-2.3) and the results look noticeably better than before.

  5. YDX-2147483647 commented on Nov 10, 2026

    @YDX-2147483647
    Contributor

    Hi admannon! The word joiner bug you mentioned in #8413 (comment) can be fixed by updating ICU4X without switching to the unstable neo segmenter. And https://github.com/haminic has submitted #9024 to do that.
    Perhaps your test case word_joiner_prevents_break_in_thai should be added to #9024?

  6. admannon commented on Nov 11, 2026

    @admannon

    Hi admannon! The word joiner bug you mentioned in #8413 (comment) can be fixed by updating ICU4X without switching to the unstable neo segmenter. And https://github.com/haminic has submitted #9024 to do that. Perhaps your test case word_joiner_prevents_break_in_thai should be added to #9024?

    I agree. word_joiner_prevents_break_in_thai would be a useful regression test.
     
    Besides the original bug, it also covers a practical use case where WORD JOINER can be used to prevent breaks inside specific words (e.g. กรุงเทพมหานคร) without modifying the dictionary.
     
    This can be useful for custom dictionary-like behavior, so I think it is worth adding as a regression test.

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

    dependenciesi18n

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions