Skip to content

Writing non-Latin (e.g. Chinese) text without a configured font leads to unpredictable font fallback #5040

Open

Description

@LaurenzV

Description

Example:

将要方翼転稿選敗経容友表機。発無生以極会知質著陸質上必者教輸。庭菊意司情門佐略駒給県間相申行。文様理能株原位万一条中意中詳破必資地加。清問明田謝暮合住経件故本性勢長夜最。第向表社旅当英佐処石済度聞連。情全知公真三告用右暮共南。焦情穴毎局兵月過初薄当大異経町。覧薄約最快業武朝員持幌豊生御節。在新大注議中警緊予荷需業治客。

Result:
image

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?

Reproduction URL

No response

Operating system

No response

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    urgent
    on Sep 26, 2024
  2. LaurenzV commented on Sep 26, 2024

    @LaurenzV
    CollaboratorAuthor

    I guess this was introduced by typst/webapp-issues#380.

  3. peng1999 commented on Sep 28, 2024

    @peng1999
    Contributor

    Maybe we should just always use Noto Sans CJK?

    Maybe just move Noto Sans CJK to the higher position of fallback list.

  4. laurmaedje commented on Oct 1, 2024

    @laurmaedje
    Member

    Maybe just move Noto Sans CJK to the higher position of fallback list.

    There isn't really one. It goes into last resort fallback here, where all bets are kinda off.

  5. added
    text
    on Oct 1, 2024
  6. laurmaedje commented on Oct 7, 2024

    @laurmaedje
    Member

    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.

  7. removed
    urgent
    on Oct 7, 2024
  8. LaurenzV commented on Oct 7, 2024

    @LaurenzV
    CollaboratorAuthor

    Fair enough. I guess we can transfer this to webapp-issues then?

  9. laurmaedje commented on Oct 7, 2024

    @laurmaedje
    Member

    Not sure. The web app has little say in font selection. It just provides a FontBook. So this might require changes in Typst.

  10. Andrew15-5 commented on Oct 28, 2024

    @Andrew15-5
    Contributor

    I agree that a better fallback font selection can be used when specifying text.lang/text.region.

  11. 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
  12. 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
  13. added
    cjk
    on Feb 10, 2025
  14. LaurenzV commented on Apr 24, 2025

    @LaurenzV
    CollaboratorAuthor

    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.

  15. laurmaedje commented on Apr 24, 2025

    @laurmaedje
    Member

    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.

  16. laurmaedje commented on Apr 24, 2025

    @laurmaedje
    Member

    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.

  17. YDX-2147483647 commented on May 5, 2026

    @YDX-2147483647
    Contributor

    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.font is not set explicitly.

  18. sijow commented on May 6, 2026

    @sijow
    Contributor

    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.

  19. YDX-2147483647 commented on May 6, 2026

    @YDX-2147483647
    Contributor

    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

    1. 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. ↩

  20. baptiste commented on Aug 14, 2026

    @baptiste

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcjktext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions