Skip to content

Strict grid for CJK, hopefully via glue #4404

@neruthes

Description

@neruthes

Description

The xeCJK package affords CJKglue and CJKecglue to allow precise control of inter-token spacing. I hope to be able to do similar in Typst. Specifically, what I intend to resemble is strict grid layout with CJK text.

In this example, the first line is bad because the 4 inter-character spacings between Hanzi/Kanji/Hanja are not zero.

image

\documentclass[12pt]{standalone}
\usepackage{fontspec,xeCJK}
\xeCJKsetup{PunctStyle=plain,RubberPunctSkip=false}

\begin{document}
    \begin{minipage}{25em}
        \leavevmode
        \vskip 2em
        \center
        \begin{minipage}{13em}
            这样是坏的This way is BAD这样是坏的

            \xeCJKsetup{PunctStyle=plain,RubberPunctSkip=false,CJKglue=\hskip 0pt,CJKecglue=\hskip 4pt plus 100cm minus 0.1pt}            
            
            这样是好的This way is good这样是好的
        \end{minipage}

        \vspace{2em}
    \end{minipage}
\end{document}

Use Case

Strict grid breaks into a few simple rules:

  • All Hanzi/Kanji/Hanja, Hiragana, Katakana, and full-width punctuation marks share exactly the same width. I have no idea about Hangeul; hopefully it does not require the same.
  • Any inter-character space between 2 of these characters is exactly 0pt wide.
  • In a justified line, the duty for stretching (when needed) is equally divided to CJK-nonCJK glues.
  • CJK-nonCJK spacing is ok to be arbitrarily large.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cjkChinese, Japanese, Korean typography.feature requestNew feature or requestlayoutRelated to the layout category, which is about composing, positioning, etc.textRelated to the text category, which is all about text handling, shaping, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions