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

Make the upcoming glyf table with cubics opt-in, behind a flag #3113

Closed
belluzj opened this issue May 22, 2023 · 5 comments · Fixed by #3119
Closed

Make the upcoming glyf table with cubics opt-in, behind a flag #3113

belluzj opened this issue May 22, 2023 · 5 comments · Fixed by #3119

Comments

@belluzj
Copy link
Contributor

belluzj commented May 22, 2023

Now that a glyf table with support for cubic curves is on the roadmap for OpenType 2.0 and that fontTools already supports that output, it can happen that such a glyf table gets produced inadvertently and results in a font that doesn't work except in bleeding-edge environments that run the latest Harfbuzz.

Previously, trying to introduce cubic béziers into the glyf table would crash, and I think it should keep crashing by default for the time being, until at least the spec of the new table format is officially released and implementers can catch up. The new format could be behind a flag, either on fontTools using the config system, or specifically on ttGlyphPens as suggested by @anthrotype .

We'll look into reproducing this issue and possibly propose a PR.

@belluzj
Copy link
Contributor Author

belluzj commented May 22, 2023

More context from @anthrotype

fontmake or ufo2ft would not currently let you build such cubic ttf fonts, because cu2qu is always run for ttfs at the moment. it's only if you build the fonts yourself (e.g. fontBuilder) using fonttools API that you may incur in this. [...] the bar for that is relatively high.

I think decompiling/compiling glyf with cubic flags should continue to work without flags of sorts. but building new cubic glyf glyphs shouhld be guarded by a flag so it doesn't happen accidentally.

@Lorp
Copy link

Lorp commented May 22, 2023

Note that you can hack test fonts relatively easily, including variable:

  1. Prepare your .designspace file and .ufo sources with cubic glyphs as normal.
  2. In all .glif files, search & replace all "curve" with "qcurve".
  3. Use fontmake to create a TrueType font from the sources:
    $ fontmake -o variable -m <yourfont.designspace>
  4. Write a tool that processes binary TTFs to:
  • for all simple glyphs, for all off-curve points, set flags bit 7
  • update head.glyphDataFormat to 1

This is based on the technique (Building ttf-cubic fonts) that I used to make experimental "ttf-cubic" fonts.

@rsheeter
Copy link
Collaborator

rsheeter commented May 22, 2023

FWIW for Google Fonts use we'd much rather have an opt-in to any capability to produce off-spec fonts. If my icon compiler (using fontbuilder) forgets to cu2qu I want an error (as was the case before), not the silent production of a binary that won't work when I deploy it.

EDIT: an explicit opt-out would be better than nothing, but it still leaves me open to someone forgetting to add it and getting a nasty, non-obvious, surprise.

@anthrotype
Copy link
Member

anthrotype commented May 22, 2023

maybe we can leave the TTGlyphPen as it is and just need to change the FontBuilder. We can add an option to FontBuilder constructor with the glyphDataFormat=0 defaulting to the currently spec'ed format (0, no cubics) and that's going to be used in the setupHead method as well; then if one passes cubic TTGlyphs to setupGlyf method and did not explicitly request glyphDataFormat=1 when making the builder, then it means they didn't want to do it intentionally and we let it fail with an error.

@behdad
Copy link
Member

behdad commented May 22, 2023

maybe we can leave the TTGlyphPen as it is and just need to change the FontBuilder. We can add an option to FontBuilder constructor with the glyphDataFormat=0 defaulting to the currently spec'ed format (0, no cubics) and that's going to be used in the setupHead method as well; then if one passes cubic TTGlyphs to setupGlyf method and did not explicitly request glyphDataFormat=1 when making the builder, then it means they didn't want to do it intentionally and we let it fail with an error.

SGTM.

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 a pull request may close this issue.

5 participants