Skip to content

Option to have raw, unchanged, surpriseless, uniform CJK full-width punctuation width #7643

Open

Description

@neruthes

Description

What I want

A beautiful, predictable, uniform matrix of glyphs with one single, static, constant width.

Image

When using xeCJK, all the requirement is a simple line:

\xeCJKsetup{PunctStyle=plain,RubberPunctSkip=false}

Current behavior

Chaotic width squeezing rules full of surprises.

Image

Proposed API

#set text(cjk-punct-width: auto | "raw")

When set to auto, which is the default value, use the current behavior. When set to "raw", use the raw, unchanged, surpriseless, uniform width.

This option should not affect how the width of sequence —— is determined, whose glyph might from a ligature of the current font.

Workaround

#show regex("[,。、]"): it => box(width: 1em, align(left, it))
#show regex("[!?;:()【】「」『』❲❳[]]"): it => box(width: 1em, align(center, it))

Mostly usable; might need further tweaking.

Use Case

Anyone migrating from XeLaTeX + xeCJK workflow will need this feature to have a fully comparable CJK environment.

Activity

  1. added
    feature request
    on Jan 1, 2026
  2. YDX-2147483647 commented on Jan 2, 2026

    @YDX-2147483647
    Contributor

    A beautiful, predictable, uniform matrix of glyphs with one single, static, constant width.

    I doubt this. Modern Chinese (I don't know much about J/K) texts contain non-square characters like 2026 and AI. By letting these widths constant, we give up a large number of adjustment opportunities, making it more difficult to adjust lines and prevent widows/orphans, which may worsen the overall layout.
    (Also, your examples ( 。。 and 。?) are rare in real world.)

    With that said, I agree that it would be good if this can be customized.
    Perhaps the API can be merged with overhang, as proposed in #261 / #6582. (#261 is a general issue, and #6582 is specific to Chinese.)
    See also https://gap.zhtyp.top/#customize-overhang

    Another workaround

    Select a text.region other than the default (CN).

    (For Typst v0.14.2)

    #set text(lang: "zh", region: "HK")
    
    (一二三?)\
    (一二?三)\
    (一。?三)\
    (一。。三)\
    (一。。。)\
    Image
  3. neruthes commented on Jan 2, 2026

    @neruthes
    Author

    contain non-square characters like 2026 and AI

    Yes, and my good old solution is \xeCJKsetup{PunctStyle=plain,RubberPunctSkip=false,CJKglue=\strut\hskip 0pt,CJKecglue=\strut\hskip 0.22em plus 200pt} which spreads all glue stretching duty to script-switching points so I still keep uniform natural width of all Hanzi/Kanji/Hanja + Hiragana + Katakana + full-width punctuation marks. To me, the matrix is paramount. (I am not familiar with Hangeul typesetting choices.)

    examples ( 。。 and 。?) are rare in real world.)

    Yes, this is an easy demo for behavior comparison. Real world uses include: 他说:「真巧啊(真的吗???),你也来了。」 (He said: "What a coincidence (really???), you came, too.").

    Perhaps the API can be merged with overhang, as proposed in #261 / #6582. (#261 is a general issue, and #6582 is specific to Chinese.) See also https://gap.zhtyp.art/#customize-overhang

    I get the point that 7643 might have sophisticated chemistry with #6582. Should we first determine punctuation natural width then overhang at line-end, or should we first determine overhang then opportunistically inflate punctuation width? It will be a hard decision. I personally believe that punctuation natural width should be decided early, before Knuth-Plass searching for minimal badness.

    I understand that the primary concern of #6582 is about overhang behavior. This issue 7643, on the other hand, concerns a behavior that can make problems independently without interaction with overhang. So I am not convinced that the "overhang" concept is large enough to cover this behavior. For single-line paragraphs, punctuation width problem surely occurs independently without overhang happening. In conclusion, my argument is that this issue suggests adding an option to treat all (or some particular?) full-width punctuation marks with the same width policy (without touching break policy or wrap policy) already being applied to Hanzi/Kanji/Hanja + Hiragana + Katakana, before justify/overhang computations.

    But you did remind me that punctuation width policy coverage might need better fine-grained tweaking, so I got a better idea:

    #set text(cjk-punct-width: auto | dictionary | "raw")
    
    #set text(cjk-punct-width: ("?": "raw", "。": auto, ";": auto))

    The cjk-punct-width parameter may also accept a map of punctuation width policy names, so a user may selectively have some raw and some other auto.

    #set text(lang: "zh", region: "HK")

    A nice trick worth recommending to other users. I personally prefer the 3rd quadrant.

  4. added a commit that references this issue on Jan 4, 2026
  5. added
    text
    cjk
    on Jan 26, 2026
  6. neruthes commented on Mar 1, 2026

    @neruthes
    Author

    Latest workaround:

    #set text(lang: "zh", font: "Noto Sans CJK SC", size: 10mm)
    #set page(margin: (210mm - 10mm * 17) / 2, background: {
      for xx in range(0,21) {
        place(top+left, dx: xx * 10mm, box(width: 0.5pt, fill: blue.lighten(66%), height: 100%))
      }
    })
    #let fix-cjk-spacing(doc) = {
        show regex(".[,。;?!)》】」』]]*"): it => {
        let s = it.text
        // Split the string into individual characters
        let chars = s.clusters()
        box(baseline: 0%, {
          for char in chars {
            box(width: 1em, align(center, text(char)))
          }
        })
      }
      doc
    }
    
    #show: fix-cjk-spacing
    哈基米,,。哈。。。。。。。。。。。。\
    哈。。,,《哈基米》(???)南北\
    
    哈基米南北绿豆哈基米南北绿豆哈基米
    
    哈基米南北绿豆!!。。。。。。。。(南北)。。。。《绿豆》
    
    哈基米南北绿豆??。。。。(南北)。。。。。《绿豆》
    
    。。。。。。。《《《哈基米》》》
    Image
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

    cjkfeature requesttext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions