You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong "monospace" font fallback for CJK characters in raw block #3385
The following text are rendered wrongly on most Windows. This is because typst usually makes font fallback to "LiSu", an ancient chinese font, or even fails to fallback to any font.
运行结果:
```请输入一个整数:16该整数的平方根为: 4.0```
Though Chinese users already have to style their documents with a template overriding many default settings, I believe it deserves to make our settings more sensible. I suggest to extend this fallback list for different systems:
It's not wise to hard encode fallback font list. It's better to detect the fallback list according to system interfaces. On MacOS this can be achieved using CTFontCopyDefaultCascadeListForLanguages, and on Linux we can use fontconfig.
In fact, abc in LiSu indeed have the same width, and they are narrower than 人一口.
However, this is also true for KaiTi, but KaiTi declares that it is not monospace…
Activity
peng1999 commentedon Feb 18, 2024
It's not wise to hard encode fallback font list. It's better to detect the fallback list according to system interfaces. On MacOS this can be achieved using
CTFontCopyDefaultCascadeListForLanguages, and on Linux we can use fontconfig.YDX-2147483647 commentedon Nov 3, 2025
This is because LiSu itself claims to be monospace, and has the shortest name.
The fallback algorithm gives priority to such fonts.
claims to be monospace: In its OpenType
posttable,isFixedPitchis nonzero.In fact,
abcin LiSu indeed have the same width, and they are narrower than人一口.However, this is also true for KaiTi, but KaiTi declares that it is not monospace…
has the shortest name: Only 4 characters, shorter than SimSun, Microsoft YaHei, etc.