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 issue with sparse masters when .notdef contain cubic curves #772

Merged
merged 2 commits into from
Aug 1, 2023

Conversation

anthrotype
Copy link
Member

@anthrotype anthrotype commented Aug 1, 2023

I first push a reproducer for the issue I raised in #501 (comment)

and then follow up with a fix.

EDIT:

previously we were copying ".notdef" glyph from the default master when a sparse layer didn't contain one already, but if the notdef contains some cubic curves then our own check fails because the .notdef that we inserted in the sparse masters' OutlineCompiler was not passed through cu2qu...
Our intention is to have sparse masters not participate in the interpolation of that particular .notdef glyph so we make it empty (a gid0=.notdef still needs to be there for a valid TTF so we must have it there).
Currently the same trick does not work for CFF2 variable fonts (fonttools/fonttools#3233) but those are fine with cubics in .notdef glyph any way.. For now at least

@anthrotype
Copy link
Member Author

as expected, the reproducer fails with:

ValueError: '.notdef' has cubic Bezier curves, but glyphDataFormat=0; either convert to quadratic (convertCubics=True) or use allQuadratic=False so that glyphDataFormat=1.

the sparse master is inheriting a .notdef glyph from the default master, but this contains cubic curves and it's not converted with cu2qu, but inserted in the outlineCompiler as is with all the cubics, leading to the above check failing.

I'd like to fix this by having the .notdef glyph for sparse masters be empty and rely on varLib treat it as missing/not participating, however this currently only works for TrueType-flavored VF builds, not for CFF2 (cf. fonttools/fonttools#3233). Therefore for now I'll only do that for TTF-VFs, since they are the ones directly affected by the above crash (given the requirement to convert cubics to quads for TTFs). For CFF/CFF2, .notdef containing cubic curves works as expected.

previously we were copying one from the default master, but if this contains cubic curves our own check fails because the .notdef we inserted in the sparse masters OutlineCompiler was not passed through cu2qu...
Our intention is to have sparse masters not participate in the interpolation of that particular glyph so we make it empty (gid0=.notdef still needs to be there in a valid TTF so we must have one).
Currently the same trick does not work for CFF2 variable fonts (fonttools/fonttools#3233) but those are fine with cubics in .notdef glyph any way.. For now at least
@anthrotype anthrotype merged commit d4747ee into main Aug 1, 2023
7 checks passed
@anthrotype anthrotype deleted the ttf-vf-empty-default-notdef branch August 1, 2023 15:19
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.

1 participant