Implementation of Chinese Emphasis Dots in Typst

Currently, Typst does not support Chinese emphasis dots(着重号). I wrote my own Typst function for Chinese emphasis dots. The effect is pretty good, but the performance may not be optimal.

#let 着重号(body) = {
  show regex("\p{sc=Han}"): it => {
    box(
      grid(
        columns: 1,
        rows: (auto, -0.05em),
        row-gutter: 0.05em,
        align(center, it),
        align(center, text("・", size: 0.8em, weight: "extrabold")),
      )
    )
  }
  body
}

Usage: #着重号[text]

For example:

自发地和大批地#着重号[产生着]

1 Like

That’s nice!

You can find previous discussions at 行间标点:着重号、专名号、书名号 · Issue #29 · typst-doc-cn/clreq · GitHub. It looks like that grid is a new implementation.

2 Likes

This might be a better solution:

#show emph: it => {
  show regex("\p{Han}+"): chars => for char in chars.text.clusters() {
    box({
      char
      emph(place(center)[•])
    })
  }
  it
}

_你好呀一二三四五六七 I am latin so I should not be affected 你好呀你好呀_

image

1 Like

With reference to some of the examples you gave, I have found that my implementation disrupts PDF text selection and searching.

In addition, the effect of the emphasis dots depends on the font.

1 Like

Your example used but clreq says:

着重号用于表示相应文本的强调、着重语气或避免歧义。其形态为标注于文字底端或顶端(横排多在下方〔底端〕、直排多在右侧〔顶端〕)的圆形中黑点,可以为U+25CF BLACK CIRCLE [●]或U+2022 BULLET [•]。

Emphasis marks, also known as emphasis dots, are symbols placed on the line head or line foot to emphasize the text, strengthen the tone, or avoid ambiguity. For horizontal writing mode, emphasis marks are placed under the characters, whereas in vertical writing mode, they are usually placed to the right side of the characters. Both U+25CF BLACK CIRCLE [●] or U+2022 BULLET [•] can work as emphasis marks.

Semantically the 着重号 is similar to emph or strong (personally I’d say it is closer to emph) using a grid to place the dots loses some accessibility. I think emph and putting a bullet inside pdf.artifact("layout") would be better. The outcome will depend on the font though.

I agree with treating Chinese emphasis dots as the equivalent of emph, because the bold (strong) markup in English often corresponds to Chinese sans-serif typefaces (Heiti, not bold per se) in practice. As for the punctuation mark I used earlier, I just picked it randomly from my input method—it was indeed inappropriate (it seems to be a Japanese character, doesn’t it?).

An improved approach, referencing the “currently best solution” mentioned in your link:

#let 着重号(body) = {
  show regex("\p{sc=Han}"): it => {
    box(
      grid(
        columns: 1,
        rows: (auto, -0.2em),
        row-gutter: 0.2em,
        align(center, it),
        align(center, circle(fill: black, width: 0.2em)),
      )
    )
  }
  body
}

One additional point: the text with emphasis dots will align flush with the text without them only when the line height of the second line (here, –0.2em) and the row‑gutter (here, 0.2em) are additive inverses.