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
Writing non-Latin (e.g. Chinese) text without a configured font leads to unpredictable font fallback #5040
Note how there are a few characters that are bolder than the rest. This is kind of a web app issue, but I'm still posting it here so I can label with with "urgent", because I think that should definitely be fixed before the next release, as it's a bad user experience. Maybe by changing the default web app fonts so that a font is chosen that supports both, Japanese and Chinese characters.
From what I can tell, the issue is that it uses MoeSong UN by default, which apparently is missing some characters, which are taken from Noto Sans CJK. Maybe we should just always use Noto Sans CJK?
I'm not sure whether it's helpful to make it slightly less bad. Relying on font fallback will always be worse than having properly configured fonts.
I think there's things we can do (like a better default font list when lang == zh or similar), and better warnings in the web app for users that do not configure the language. But just changing the fallback order feels like a band-aid fix to me.
changed the title [-]Writing Chinese text results in some characters falling back to a different font in web app[/-][+]Writing Chinese text without a configured font leads to unpredictable font fallback[/+]on Jan 25, 2025
changed the title [-]Writing Chinese text without a configured font leads to unpredictable font fallback[/-][+]Writing non-Latin (e.g. Chinese) text without a configured font leads to unpredictable font fallback[/+]on Jan 25, 2025
But just changing the fallback order feels like a band-aid fix to me.
I think it's worth it to provide a band-aid fix for the web app, just so that the default user experience for CJK users that are using the web app for the first time isn't affected by this.
I'm not sure whether it's really better to make it slightly less bad because then it might be just good enough to not configure a proper font, but still bad.
Relying on the local fontconfig setup would mean that the output is not reproducible though... If the user moves the document to the webapp or sends it to a collaborator, it would silently compile to a wrong output. I'd rather have smart warnings that show up until the fonts are properly configured.
I don't have a strong opinion about the fontconfig proposal1, but I want to emphasize that there are two types of reproducibility here:
same font setup + same main.typ + different platforms (Windows, Linux, typst.app) ⇒ same result
same font setup + different tools (Typst, LaTeX, matplotlib, Firefox, IME) + same platform ⇒ same result
If what Maxwell said is true, then the fontconfig proposal will make it harder to achieve the first type of reproducibility, but make it easier to achieve the second.
I believe that we should not merely focus on the first type of reproducibility. In any case, sharing a Typst document can never be more reproducible than two people in a cloud meeting sharing an online realtime whiteboard, because the latter doesn't even need any font setup.
Footnotes
In fact, I'm not familiar with fontconfig. I rarely use Linux with GUI or comprehensive font setup; and on Windows, TeX Live is the only software that I know it uses fontconfig. ↩
Could the web app issue warnings, like it does errors and suggestions? Here it could be "if the user did not set an explicit set text(lang:) AND some body text is non-latin AND a font fallback has occurred invisibly" then issue a warning+suggestion that the appearance may be bad and suggest to add #set text(language: , font: "") at the top, and maybe also mention fallback?
Activity
LaurenzV commentedon Sep 26, 2024
I guess this was introduced by typst/webapp-issues#380.
peng1999 commentedon Sep 28, 2024
Maybe just move Noto Sans CJK to the higher position of fallback list.
laurmaedje commentedon Oct 1, 2024
There isn't really one. It goes into last resort fallback here, where all bets are kinda off.
laurmaedje commentedon Oct 7, 2024
I'm not sure whether it's helpful to make it slightly less bad. Relying on font fallback will always be worse than having properly configured fonts.
I think there's things we can do (like a better default font list when lang == zh or similar), and better warnings in the web app for users that do not configure the language. But just changing the fallback order feels like a band-aid fix to me.
LaurenzV commentedon Oct 7, 2024
Fair enough. I guess we can transfer this to
webapp-issuesthen?laurmaedje commentedon Oct 7, 2024
Not sure. The web app has little say in font selection. It just provides a FontBook. So this might require changes in Typst.
Andrew15-5 commentedon Oct 28, 2024
I agree that a better fallback font selection can be used when specifying
text.lang/text.region.[-]Writing Chinese text results in some characters falling back to a different font in web app[/-][+]Writing Chinese text without a configured font leads to unpredictable font fallback[/+][-]Writing Chinese text without a configured font leads to unpredictable font fallback[/-][+]Writing non-Latin (e.g. Chinese) text without a configured font leads to unpredictable font fallback[/+]LaurenzV commentedon Apr 24, 2025
I think it's worth it to provide a band-aid fix for the web app, just so that the default user experience for CJK users that are using the web app for the first time isn't affected by this.
laurmaedje commentedon Apr 24, 2025
I'm not sure whether it's really better to make it slightly less bad because then it might be just good enough to not configure a proper font, but still bad.
laurmaedje commentedon Apr 24, 2025
I guess it also depends on whether you just have a bit of Chinese text or a document full of it. In the former case, it might be enough.
YDX-2147483647 commentedon May 5, 2026
Maxwell pointed out on the Forum that fontconfig has a mechanism for manually adjusting the priority of fonts (e.g.,
~/.config/fontconfig/fonts.conf). One can put Noto Serif CJK SC before Noto Serif CJK JP by leveraging this mechanism (SC comes after JP in alphabetical order).It is said that the mechanism is supported by operating systems, browsers, terminals, and many softwares.
Maxwell suggests that Typst should respect fontconfig if
text.fontis not set explicitly.sijow commentedon May 6, 2026
Relying on the local fontconfig setup would mean that the output is not reproducible though... If the user moves the document to the webapp or sends it to a collaborator, it would silently compile to a wrong output. I'd rather have smart warnings that show up until the fonts are properly configured.
YDX-2147483647 commentedon May 6, 2026
I don't have a strong opinion about the fontconfig proposal1, but I want to emphasize that there are two types of reproducibility here:
main.typ+ different platforms (Windows, Linux, typst.app) ⇒ same resultIf what Maxwell said is true, then the fontconfig proposal will make it harder to achieve the first type of reproducibility, but make it easier to achieve the second.
I believe that we should not merely focus on the first type of reproducibility. In any case, sharing a Typst document can never be more reproducible than two people in a cloud meeting sharing an online realtime whiteboard, because the latter doesn't even need any font setup.
Footnotes
In fact, I'm not familiar with fontconfig. I rarely use Linux with GUI or comprehensive font setup; and on Windows, TeX Live is the only software that I know it uses fontconfig. ↩
baptiste commentedon Aug 14, 2026
Could the web app issue warnings, like it does errors and suggestions? Here it could be "if the user did not set an explicit
set text(lang:)AND some body text is non-latin AND a font fallback has occurred invisibly" then issue a warning+suggestion that the appearance may be bad and suggest to add#set text(language: , font: "")at the top, and maybe also mention fallback?Just a thought!