Skip to content

Fix panic with empty color glyphs#1765

Merged
anthrotype merged 3 commits into
mainfrom
repro-colr-empty-shapes
Nov 19, 2025
Merged

Fix panic with empty color glyphs#1765
anthrotype merged 3 commits into
mainfrom
repro-colr-empty-shapes

Conversation

@anthrotype

Copy link
Copy Markdown
Member

This test reproduces a panic when compiling

python3 -m ttx_diff 'https://github.com/EkType/Honk?99094d4f6e#sources/HonkExportFile.glyphs'

whereby an empty glyph 'CR' has palette layers that trigger the COLRv0 code path, however those layers have no shapes.

These empty glyphs are being unconditionally added to color_glyphs despite actually having no shapes.

This test reproduces a bug where a glyph like 'CR' has palette layers
that trigger the COLRv0 code path, but those layers have no shapes.
The test verifies that such glyphs are not incorrectly added to color_glyphs.
This test reproduces the same bug as the COLRv0 test but for the COLRv1 split code.
Comment thread glyphs2fontir/src/toir.rs
},
],
..Default::default()
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: would it be easier to just add a new source?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe.. but I have already done it

When a glyph has color layers (palette layers for COLRv0 or color attribute
for COLRv1) but those layers have no shapes, the glyph was incorrectly added
to color_glyphs with empty split_glyph_names. This caused a panic when trying
to access shapes[0] in create_paint_glyph.

The fix checks if there's actual color content before adding the glyph

Also improved error handling in create_paint_glyph to return a proper error
instead of panicking if a color glyph unexpectedly has no shapes.

Fixes compilation of HonkExportFile.glyphs font.
@anthrotype

Copy link
Copy Markdown
Member Author

after this patch Honk gets 90.337% COLR

@anthrotype anthrotype added this pull request to the merge queue Nov 19, 2025
Merged via the queue into main with commit aa632a1 Nov 19, 2025
12 checks passed
@anthrotype anthrotype deleted the repro-colr-empty-shapes branch November 19, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants