Skip to content

TrueType fonts with 65536 glyphs render tofus in PNG and SVG export #8434

Open

Description

@laurmaedje

Description

ttf-parser chokes on fonts with 65536 (2^16) glyphs because the following conversion exceeds u16's range:

https://github.com/harfbuzz/ttf-parser/blob/6e75b3c539ef6bfbacb020aaa3226414ddea7ce5/src/tables/loca.rs#L50

In PDF, ttf-parser isn't used anymore, that's why it works there.

Operating system

No response

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    svg
    png
    upstream
    on Jun 4, 2026
  2. laurmaedje commented on Jun 4, 2026

    @laurmaedje
    MemberAuthor

    Workaround: Use OTF versions of fonts instead, if available.

  3. changed the title [-]TrueType fonts with 65536 render tofus in PNG and SVG export[/-] [+]TrueType fonts with 65536 glyphs render tofus in PNG and SVG export[/+] on Jun 4, 2026
  4. YDX-2147483647 commented on Jul 6, 2026

    @YDX-2147483647
    Contributor

    Is it possible to emit a warning or ignore such fonts?

    Today one more person encountered this issue when using tinymist VS Code preview (it depends on SVG, so it's affected). This is at least the fourth time I know.

    This issue creates a lot of confusion due to the following reasons:

    • SVG is broken but PDF is okay, so it's not easy to reproduce.

    • Source Han Sans/Serif release variable TTFs, variable OTFs, and static OTFs. And Typst selects variable versions over static versions.

      As a result, if you've installed the variable TTF, then installing static OTF won't circumvent the problem unless you uninstall the variable TTF.

      An extremely confusing special case is SourceHanSerif-VF.ttf.ttc/SourceHanSans*-VF.ttf.ttc. Each *.ttc collection file packs multiple variable TTF typefaces, including Source Han Sans/Serif SC VF. In other words, a static OTF with the SC suffix might be shadowed by a varaible TTF file whose file name doesn't even contain the SC suffix.

    (The official web app isn't affected, because Source Han Sans/Serif VF are not built-in, and they are too large to upload. See typst/webapp-issues#894.)

  5. laurmaedje commented on Jul 6, 2026

    @laurmaedje
    MemberAuthor

    Is it possible to emit a warning or ignore such fonts?

    We'll migrate away from ttf-parser anyways during this release cycle. See #8172.

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

    bugpngsvgupstream

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions