googlefonts / nanoemoji

A wee tool to build color fonts.
Apache License 2.0
239 stars 19 forks source link

Highly sophisticated notdef glyph #379

Closed rsheeter closed 2 years ago

rsheeter commented 2 years ago

A font without a glyph data table fails OTS. A font with no glyphs with outlines emits a 1 byte glyf table but will emerge from woff2 with a 0 byte glyf. Provide a definition of notdef to avoid getting into this situation.

Currently I've only done this when we're actually generating glyf but I suspect even when there is no glyf or cff table (say a pure SVG font) we might want to add something to increase the odds things Just Work.

anthrotype commented 2 years ago

Currently I've only done this when we're actually generating glyf but I suspect even when there is no glyf or cff table (say a pure SVG font) we might want to add something to increase the odds things Just Work.

We always add an empty table when color format is picosvg or untouchedsvg (glyf or CFF, depending on the file extension suffix of the --output_file flag is respectively .ttf or .otf), the table is never actually missing, it's empty but it's there.

I see you draw the notdef glyph only inside _colr_ufo method if format starts with glyf, which means it only gets drawn for glyf-flavored COLR v0 or v1 format. But my understanding was that the issue with OTS complaining about empty outline table was to do with OT-SVG font inside FireFox.. I'd expect that the notdef drawing method be moved to where we actually create our temporary UFO (inside _ufo method), regardless of the color/output format, be it COLR, SVG, glyf or CFF.

anthrotype commented 2 years ago

+1 if we allow user to draw their own .notdef glyph, we would special case it in the list of input SVGs and use that one if present, or fall back to draw one if missing

rsheeter commented 2 years ago

notdef drawing method be moved to where we actually create our temporary UFO

Good catch, fixed. You can still achieve OTS failure by subsetting and dropping the notdef outline but who would do such a thing!