Repository navigation
Description
Description
At present, text.font for main text, raw, and math.equation are controlled separately.
And none of the default fonts1 provides glyphs for CJK / Han / East Asian characters.
As a result, to those who use such characters, sometimes it's necessary to specify the fallback font (e.g., Noto Serif CJK SC) for three times:
#set text(font: (
(name: "Libertinus Serif", covers: "latin-in-cjk"),
"Noto Serif CJK SC",
))
#show math.equation: set text(font: (
"New Computer Modern Math",
"Noto Serif CJK SC",
))
#show raw: set text(font: (
"DejaVu Sans Mono",
"Noto Serif CJK SC",
))I suggest Typst changes the fallback rule in math and raw to the following.
- Try the
text.fontfor math/raw as usual. - If missing glyph, try the
text.fontfor main text. - If still missing, try other available fonts as usual.
Following this rule, the above configuration can be simplified as:
#set text(font: (
(name: "Libertinus Serif", covers: "latin-in-cjk"),
"Noto Serif CJK SC",
))I guess this shouldn't be hard to implement. A special Fold is likely to work.
Use Case
This will make it easier to configure the font.
That really matters, because writing CJK without configuring font leads to unpredictable font fallback. (main text: #5040, #5900, #590; raw: #3385, #5748; math: #6737)
How to typeset two‑line text in a mathematical formula? - Questions - Typst Forum gives a realistic example for math:
Additional considerations
-
This proposal is kind of an alternative to Text in math mode should use text font #366. The different is that Text in math mode should use text font #366 does not cover missing math symbols and raw, but this proposal does.
-
The current fallback rule for raw is different from that for main text and math.
In raw, monospace fonts take precedence; but in main text and math, proportional fonts take precedence.All Han characters are squares, so most CJK fonts are monospace, but the font files may or may not claim to be monospace (
isFixedPitchin the OpenTypeposttable).Further consideration may be necessary here.
Footnotes
-
Default fonts: Libertinus Serif for main text, DejaVu Sans Mono for
raw, New Computer Modern Math formath.equation. ↩
Activity