Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check in parse_charset #148

Merged
merged 3 commits into from
May 24, 2024
Merged

Fix check in parse_charset #148

merged 3 commits into from
May 24, 2024

Conversation

LaurenzV
Copy link
Contributor

So, I'm not entirely sure if this is how it's supposed to be resolved. I was using ttf-parser as a fuzzer for my subsetter, and realized that parse_charset has this check to return None when there is only one glyph (i.e. the .notdef glyph) in the font. This means that it will fail to parse the cff table in that case. However, I would argue that a font with just the .notdef glyph should be perfectly fine in theory (even though in practice this obviously doesn't make a lot of sense), because the .notdef glyph can have outlines as well.

@RazrFalcon
Copy link
Owner

I'm not sure. If we have just one glyph in a font then charset will be empty. But I guess this way we would have an empty charset and not None. Very confusing.
Ok, I guess this change is correct.

@RazrFalcon
Copy link
Owner

Can you replace the check with number_of_glyphs == 0 for readability?

@LaurenzV
Copy link
Contributor Author

So actually, we already check that the number of glyphs is nonzero:
image

So I guess we can remove this check completely? It's got nothing to do with the charset after all...

@RazrFalcon
Copy link
Owner

Then parse_charset should accept NonZeroU16 and not u16.

@RazrFalcon RazrFalcon merged commit dabe8a5 into RazrFalcon:master May 24, 2024
2 checks passed
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