Skip to content

Support bitmap fonts #4335

@Nerixyz

Description

@Nerixyz

Description

Currently, attempting to use glyphs from fonts that have the raster image type other than PNG panics with:

failed to decode image (Format error decoding Png: Invalid PNG signature.)

in draw_raster_glyph, because it assumes every color glyph has the image type PNG.

I'm not exactly sure what these fonts are called, as FontForge refuses to open it, because its name isn't ASCII 🙃

I made a patch to at least add support for BitmapMonoPacked (the type of glyphs in SimSun) in Nerixyz@4188128, however I don't think that's the correct approach. Since the bitmap is monochrome, it should be fine to color it (→ it should be rendered as a "regular" glyph in render_text). Since I'm new to the codebase, I wanted to ask where I should add support for the monochrome glyphs.

Use Case

At least on Windows, Typst falls back to the SimSun font for Chinese characters. When rendering to PNG, Typst currently panics (not really a compiler bug, I'd say, more like a missing feature).

For example, a Typst file having just compiled as PNG will panic on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requesttextRelated to the text category, which is all about text handling, shaping, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions