Skip to content

Throw a Warning when a Font is not Found #2818

Closed

Description

@adamkrellenstein

Description

When setting the font say globally, with #set text(font: "abcdefg"), if the font is not found (say because it doesn't exist), the output of typst compile doesn't change and the compiler doesn't throw any errors. An error should also be thrown if the appropriate weight/size/etc. cannot be used.

Use Case

This follows the Principle of Least Surprise: if you manually set the font and the output doesn't change, that's strange. The compiler should throw an error (or at the very least, a warning).

Activity

  1. changed the title [-]Throw an Error when a Required Font is not Found[/-] [+]Throw an Error when a Font is not Found[/+] on Dec 1, 2023
  2. maxcrees commented on Dec 1, 2023

    @maxcrees

    The docs indicate that it is planned to issue a warning if a font is specified and fallbacks are disabled:

    Note: Currently, there are no warnings when fallback is disabled and no glyphs are found. Instead, your text shows up in the form of "tofus": Small boxes that indicate the lack of an appropriate glyph. In the future, you will be able to instruct Typst to issue warnings so you know something is up.

    https://typst.app/docs/reference/text/text/#parameters-fallback

    I don't think this is implemented yet however - and I'm on mobile so I can't test at the moment.

  3. Enivex commented on Dec 1, 2023

    @Enivex
    Collaborator

    It should definitely not throw an error, but a warning is indeed planned.

    I was sure there was an issue tracking this, but couldn't find one, so I guess this can stay up. Though I'd prefer if you changed the title to warning @adamkrellenstein

  4. added
    text
    diagnostics
    on Dec 1, 2023
  5. changed the title [-]Throw an Error when a Font is not Found[/-] [+]Throw an Warning when a Font is not Found[/+] on Dec 1, 2023
  6. adamkrellenstein commented on Dec 1, 2023

    @adamkrellenstein
    Author

    It seems to me that a warning should still be printed even when fallbacks are not disabled.

    IMO this warning should also identify [the first n] missing glyphs and the source of their replacements.

  7. changed the title [-]Throw an Warning when a Font is not Found[/-] [+]Throw a Warning when a Font is not Found[/+] on Dec 1, 2023
  8. PPakalns commented on Dec 1, 2023

    @PPakalns

    I would suggest to add an option for typst to throw warnings as errors, similarly as it is done in C++, C with -Werror flag.

    Typst is being integrated into scripts that compiles documents and missing fonts are important issue that needs to be easily detectable by automated scripts and could be missed while parsing stdout because between versions warning text could change. I would prefer not compiling document and returning non zero status code/error vs parsing stdout.

  9. Enivex commented on Dec 1, 2023

    @Enivex
    Collaborator

    I would suggest to add an option for typst to throw warnings as errors, similarly as it is done in C++, C with -Werror flag.

    Typst is being integrated into scripts that compiles documents and missing fonts are important issue that needs to be easily detectable by automated scripts and could be missed while parsing stdout because between versions warning text could change. I would prefer not compiling document and returning non zero status code/error vs parsing stdout.

    This would be covered by #1967 no?

  10. laurmaedje commented on Jul 15, 2024

    @laurmaedje
    Member

    Closed by #3854

  11. hooyuser commented on Dec 4, 2025

    @hooyuser
    Contributor

    I was planning to open a feature request to enable warnings when there is a mismatch in font weight, style, or stretch. However, I noticed that this closed issue already requested something similar:

    An error should also be thrown if the appropriate weight/size/etc. cannot be used.

    Before I open a new issue, I wanted to confirm: is this closed issue considered fully resolved? Should I submit a new issue, or should I ask for the closed one to be reopened?

    Related PR: #3352 #3354

  12. laurmaedje commented on Dec 4, 2025

    @laurmaedje
    Member

    Please submit a new issue.

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

    diagnosticsfeature requesttext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions