Universe

logo

chiandiau (腔調, Chinese tone of voice; Shanghainese model behavior) is a Typst package to generate Jumpy Pronunciation (跳跳紮注音) for any Chinese variaties or any other toned languages using Chao tone letters.

Quick start

#import "@preview/chiandiau:0.1.0": *
#wuu-wugniu(
  "新冠防护勿放松,上海市民有腔调",
  "1shin-kuoe 6vaon-wu 6veq8-faon-son 6zaon-he 6zy-min 6yeu 1chian-diau",

  // optional parameters
  pron-font: ..., // custom font (name / list) for pronunciation
  // see below for more
)

Examples

… of all available pre-defined writing systems. Check the repo on GitHub for demo.typ.

Built-in schemes

  • cmn:
    • 成都話拼音 cmn-cyuc-sicuan
    • 四川話通用拼音 cmn-xghu-tongyong
      • scheme: "Guiyang" | "Anshun" | "Liuzhi" | "Xingyi" | "Hanyin" | "Zhenba" | "Shiqian" | "Chengdu" | "Tongren" | "Guanyuan" | "Nanchong" | "Mianyang" | "Wanzhou", default "Chengdu"
  • nan: 臺灣台語羅馬字 nan-tailo (compatible with Pe̍h-ōe-jī)
  • wuu: 吳語學堂拼音 wuu-wugniu
    • append \ and tone after a syllable, like 8geh-soh7\55 to make soh become 55
    • scheme: see wuu.typ on how to pass custom schemes
  • yue: 粤拼 yue-jyutping

Additionally, all schemes accepts ..attrs that will be passed to cd() (see below).

Advanced usage

Write a new scheme

#let cmn-pinyin-scheme = (
  none,
  55,
  35,
  214, // unimplemented; use 14
  53,
)

#let cmn-pinyin(zh, pron, ..attrs) = {
  let pairs = to-pairs(zh, pron)
  cd(
    pairs,
    scheme: to-scheme(cmn-pinyin-scheme),
    ..attrs
  )
}

to-scheme and to-pairs cannot handle those with tone sandhi, so this sample will not deal with morphemes like 不 (bù; ‘not’) and 一 (yī; ‘one’). in Standard Chinese. Use to-sandhi-pairs instead.

Use cd()

cd accepts either:

  • pairs: (zi: str, pron: str) + scheme: (pron: str) => conter, or
  • pairs: (zi: str, pron: str, conter: int).

Here conter means the Chao tone number like $1$, $35$, $42$, etc.

Optional parameters

  dir: direction.btt, // note that zi is before pron
  pron-font: context text.font, // or font name / list
  pron-size: .4em, // of zi font size which is .4em of 2em = .8em
  width: "monospace", // or `auto` or fixed value like `1.2em`
  pron-style: none, // or a function
  debug: false, // show border of boxes

Roadmap

  • [ ] 3-digit tone numbers
  • [ ] Tone sandhi by character
  • [ ] More built-in schemes
  • [ ] Backgrounds for tone boxes

Contributing

Feedback, bugfix, or new scheme support are all welcome!

Acknowledgement

License

The source code is released under the Apache 2.0 License.