Skip to content

In Chinese typsetting, Interpunct (U+00B7) should not appear at line start and should have consistent width #6774

Open

Description

@chiefaccelerators

Description

Right now the Chinese punctuation handling is mostly okay, but interpunct is one exception. Per clreq:

The width of interpuncts varies in different regions. In principle, in Hong Kong and Taiwan, interpuncts should have the same dimensions as a Hanzi in both vertical writing mode and horizontal writing mode. In Mainland China, interpuncts take up half the space of a Hanzi.

interpuncts should not appear at the line start.

Interpunct can use various codepoints, but most Chinese input methods produce U+00B7, so it's what I'm testing:

Image

Granted, the width thing is also partly a font issue and can be easily patched with a show rule. But it would save some trouble if typst can give it a consistent width based on the current lang and region setting.

Reproduction URL

No response

Operating system

Web app

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Aug 16, 2025
  2. added
    text
    cjk
    on Aug 17, 2025
  3. YDX-2147483647 commented on Sep 2, 2025

    @YDX-2147483647
    Contributor

    Perhaps the width of interpuncts can be adjusted. At present, clreq descriptions are inconsistent. (I created w3c/clreq#705.) Therefore, I suggest postponing the implementation.

    Nevertheless, the prohibition rules for line start can be fixed first.
    The only existing test case that contains interpuncts is text-chinese-basic.

    --- text-chinese-basic ---
    // Test basic Chinese text from Wikipedia.
    #set text(font: "Noto Serif CJK SC")
    是美国广播公司电视剧《迷失》第3季的第22和23集,也是全剧的第71集和72集
    由执行制作人戴蒙·林道夫和卡尔顿·库斯编剧,导演则是另一名执行制作人杰克·本德
    节目于2007年5月23日在美国和加拿大首播,共计吸引了1400万美国观众收看
    本集加上插播广告一共也持续有两个小时

  4. cocoAutumn commented on Oct 6, 2025

    @cocoAutumn

    Even in the national standard itself, the witdh of interpunct is still not well-defined.
    https://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=22EA6D162E4110E752259661E1A0D0A8

    (横排文稿标点符号的位置和书写形式)
    5.1.7 间隔号标在需要隔开的项目之间,占【半个字】位置,上下居中,不出现在一行之首。(half-width)

    But in the following examples they are all full-width.
    Image
    Since different fonts often make interpunct only half-width or even thinner, in many plain-text environment people may use U+30FB (Katakana Middle Dot) to ensure the full-width, which is not easy to input for non-Japanese users.

  5. YDX-2147483647 commented on Oct 6, 2025

    @YDX-2147483647
    Contributor

    Hi cocoAutumn!
    I guess the consensus is that the width of interpuncts is controversial.
    I suggest moving further discussions to w3c/clreq#705 rather than continuing here. w3c/clreq has a wider audience and it's more convenient to cite Chinese materials.
    Besides, you might be interested in The Type — 文字 / 设计 / 文化 — #189:十二部委联合发文指定的标点 (broadcast).

  6. YDX-2147483647 commented on Oct 28, 2025

    @YDX-2147483647
    Contributor

    The CLReq editorial group discussed and closed the issue on the width of interpuncts (w3c/clreq#705). Their conclusion is that the rule can be chosen freely. In practice, most fonts prefer 1em.
    Therefore, I suggest we respect the choice made by the font designer, and do not change the width unless we provide an option in the future.

    The original reply is as follows.

    Chinese (original):

    经过 2025 年 9 月的编辑会确认,上述引用的几条文本在内容逻辑上并不互斥,是可行的。

    需要指出的是,实际的标点宽度调整取决于排版风格,各个地区、各种媒介和作品可以自行决定调整或者不调整。本文档偏重指出原则,重点会指出「不应该做」的部分,而没有言及的部分,是留出「可做可不做」的余地供各个具体设计个案做决策。

    即便中国国标GB/T 15834—2011规定间隔号占半个汉字宽度,但该国标仅为推荐国标,目前大部分的字体也会将其制作成一个汉字宽度,最终由用户决定是否调整。

    English (translated):

    After the editorial meeting in September 2025, it was confirmed that the several quoted texts mentioned above are not mutually exclusive in terms of content logic and are feasible.

    It should be noted that the actual adjustment of punctuation width depends on the layout style. Different regions, media and works can decide for themselves whether to adjust or not. This document focuses on highlighting principles, with a particular emphasis on the parts that "should not be done". For the parts not mentioned, it leaves room for "what can be done or not done" for each specific design case to make decisions.

    Even though the Chinese national standard GB/T 15834—2011 stipulates that the space should occupy half the width of a Chinese character, this national standard is only a recommended one. Currently, most fonts will be made to the width of one Chinese character, and ultimately it is up to the user to decide whether to adjust.

  7. kands-code commented on Jan 20, 2026

    @kands-code

    I would like to add that the full-width semicolon ; should also be prohibited from appearing at the start of a line. It should follow the same punctuation compression rules as the ideographic full stop 。.

    Image
  8. YDX-2147483647 commented on Jan 20, 2026

    @YDX-2147483647
    Contributor

    Hi, @kands-code!

    As shown below, Typst does have prohibition rules for ;. It's just that the rules don't work well with math. I suggest creating a new issue instead.

    Edit: My conclusion was correct, but my analysis was wrong! The linebreak opportunities are determined by icu_segmenter. Typst's codes here are only for punctuation adjustments.

    The old wrong analysis

    // The CJK punctuation that can appear at the beginning or end of a line.
    pub const BEGIN_PUNCT_PAT: &[char] =
    &['“', '‘', '《', '〈', '(', '『', '「', '【', '〖', '〔', '[', '{'];
    pub const END_PUNCT_PAT: &[char] = &[
    '”', '’', ',', '.', '。', '、', ':', ';', '》', '〉', ')', '』', '」', '】',
    '〗', '〕', ']', '}', '?', '!',
    ];

    #set page(height: auto, margin: 1em)
    #set text(lang: "zh", font: "Noto Serif CJK SC")
    #set box(fill: green, height: 1em)
    
    #set page(width: 8em + 2 * 1em)
    
    山巅一寺一壶酒;
    
    山巅一寺一壶酒酒
    
    山巅一寺一壶酒酒;
    
    山巅一寺一壶酒 $pi$;
    
    $pi$ 山巅一寺一壶酒
    
    $pi$ 山巅一寺一壶酒;
    Image

    See also 有没有标点避头尾规则? - Search | DeepWiki

    As for compressing ;, I believe the current implementation matches your description and there isn't any issue.

  9. YDX-2147483647 commented on Jan 24, 2026

    @YDX-2147483647
    Contributor

    interpuncts should not appear at the line start.

    This might be an upstream bug. icu_segmenter determines linebreak opportunities, and it thinks linebreaks can happen immediately after ·.

    ICU4X 2.1's default segmenter:
    |《女|神|·|天|狗》:“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是 |X |光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”(郭|沫|若)|
    
    ICU4X 2.1's zh auto segmenter:
    |《女|神|·|天|狗》:“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是 |X |光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”(郭|沫|若)|
    
    ICU4X 2.1's zh LSTM segmenter:
    |《女|神|·|天|狗》:“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是 |X |光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”(郭|沫|若)|
    
    ICU4X 1.4's default segmenter:
    |《女|神|·|天|狗》:“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是 |X |光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”(郭|沫|若)|
    
    Typst's CJ segmenter (ICU4X 1.4 fork):
    |《女|神|·|天|狗》:|“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是 |X |光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”|(郭|沫|若)|
    

    Expected:

    |《女|神·|天|狗》:|“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是 |X |光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”|(郭|沫|若)|
    
    Test code
    cargo run --release --features v2
    cargo run --release --features v1   
    static EXAMPLE_TEXT: &str = "《女神·天狗》:“我是月的光,我是日的光,我是一切星球的光,我是 X 光线的光,我是全宇宙的 Energy 的总量!”(郭沫若)";
    
    #[cfg(feature = "v1")]
    mod imports {
        pub use icu_provider_adapters_v1::fork::ForkByKeyProvider;
        pub use icu_provider_blob_v1::BlobDataProvider;
        pub use icu_segmenter_v1::LineSegmenter;
        pub use typst_assets::icu::{ICU, ICU_CJ_SEGMENT};
    }
    #[cfg(feature = "v1")]
    use imports::*;
    
    #[cfg(feature = "v1")]
    fn main() {
        // Default auto segmenter (ICU4X 1.4)
        println!("ICU4X 1.4's default segmenter:");
        let auto = LineSegmenter::new_auto();
        print_segments(&auto, EXAMPLE_TEXT);
    
        // CJ segmenter (Typst-custom line break data for zh/ja)
        println!("\nTypst's CJ segmenter (ICU4X 1.4 fork):");
        let cj_blob = BlobDataProvider::try_new_from_static_blob(ICU_CJ_SEGMENT).unwrap();
        let default_blob = BlobDataProvider::try_new_from_static_blob(ICU).unwrap();
        let cj_provider = ForkByKeyProvider::new(cj_blob, default_blob);
        let cj = LineSegmenter::try_new_lstm_with_buffer_provider(&cj_provider).unwrap();
        print_segments(&cj, EXAMPLE_TEXT);
    }
    
    #[cfg(feature = "v1")]
    fn print_segments(segmenter: &LineSegmenter, text: &str) {
        let mut current = 0;
        for breakpoint in segmenter.segment_str(text) {
            let slice = &text[current..breakpoint];
            print!("{}|", slice);
            current = breakpoint;
        }
        print!("\n");
    }
    
    #[cfg(feature = "v2")]
    use icu_segmenter_v2::{LineSegmenter, LineSegmenterBorrowed, options::LineBreakOptions};
    
    #[cfg(feature = "v2")]
    fn main() {
        // Default auto segmenter (ICU4X 2.1)
        println!("ICU4X 2.1's default segmenter:");
        let auto = LineSegmenter::new_auto(Default::default());
        print_segments(&auto, EXAMPLE_TEXT);
    
        let langid = "zh".parse().unwrap();
        let zh_options = {
            let mut options = LineBreakOptions::default();
            options.content_locale = Some(&langid);
            options
        };
    
        println!("\nICU4X 2.1's zh auto segmenter:");
        let localized = LineSegmenter::new_auto(zh_options);
        print_segments(&localized, EXAMPLE_TEXT);
    
        println!("\nICU4X 2.1's zh LSTM segmenter:");
        let localized = LineSegmenter::new_lstm(zh_options);
        print_segments(&localized, EXAMPLE_TEXT);
    }
    
    #[cfg(feature = "v2")]
    fn print_segments(segmenter: &LineSegmenterBorrowed<'_>, text: &str) {
        let mut current = 0;
        for breakpoint in segmenter.segment_str(text) {
            let slice = &text[current..breakpoint];
            print!("{}|", slice);
            current = breakpoint;
        }
        print!("\n");
    }
    [package]
    name = "test-icu_segmenter"
    version = "0.1.0"
    edition = "2024"
    
    [dependencies]
    # typst-assets used by typst main
    typst-assets = { git = "https://github.com/typst/typst-assets", rev = "57a38ca98", optional = true }
    
    # ICU4X v1, used by typst main
    icu_segmenter_v1 = { package = "icu_segmenter", version = "1.4", features = ["serde"], optional = true }
    icu_provider_v1 = { package = "icu_provider", version = "1.4", features = ["sync"], optional = true }
    icu_provider_adapters_v1 = { package = "icu_provider_adapters", version = "1.4", optional = true }
    icu_provider_blob_v1 = { package = "icu_provider_blob", version = "1.4", optional = true }
    
    # ICU4X v2, its latest version
    icu_segmenter_v2 = { package = "icu_segmenter", version = "2.1.2", features = ["serde"], optional = true }
    icu_provider_v2 = { package = "icu_provider", version = "2.1.1", optional = true }
    
    [features]
    default = []
    v1 = [
        "dep:typst-assets",
    	"dep:icu_segmenter_v1",
    	"dep:icu_provider_v1",
    	"dep:icu_provider_adapters_v1",
    	"dep:icu_provider_blob_v1",
    ]
    v2 = [
    	"dep:icu_segmenter_v2",
    	"dep:icu_provider_v2",
    ]

    Relates to #7412, #1355, unicode-org/icu#223, unicode-org/icu4x#3284.

    Update on 2026-10-26

    I confirm that the neo segmenter provided by icu4x 2.4 resolves this problem. See #9003.

    default segmenter:
    |《女|神|·|天|狗》:“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是|X|光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”(郭|沫|若)|
    
    neo segmenter:
    |《女|神·|天|狗》:|“我|是|月|的|光,|我|是|日|的|光,|我|是|一|切|星|球|的|光,|我|是|X|光|线|的|光,|我|是|全|宇|宙|的 |Energy |的|总|量!”|(郭|沫|若)|
    
    Test code
    use icu_segmenter::{LineSegmenter, LineSegmenterBorrowed};
    
    fn main() {
        let example_text = "《女神·天狗》:“我是月的光,我是日的光,我是一切星球的光,我是X光线的光,我是全宇宙的 Energy 的总量!”(郭沫若)";
    
        // Default auto (LSTM) segmenter
        println!("default segmenter:");
        let auto = LineSegmenter::new_auto(Default::default());
        print_segments(&auto, example_text);
    
        // Neo segmenter
        println!("\nneo segmenter:");
        let neo = LineSegmenter::new_neo_for_non_complex_scripts(Default::default());
        print_segments(&neo, example_text);
    }
    
    fn print_segments(segmenter: &LineSegmenterBorrowed<'_>, text: &str) {
        let mut current = 0;
        for breakpoint in segmenter.segment_str(text) {
            let slice = &text[current..breakpoint];
            print!("{}|", slice);
            current = breakpoint;
        }
        print!("\n");
    }
    [package]
    name = "test-icu_segmenter"
    version = "0.1.0"
    edition = "2024"
    
    [dependencies]
    icu_segmenter = { package = "icu_segmenter", version = "2.4.0", features = ["unstable"] }
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

    bugcjktext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions