googlefonts / ufo2ft

A bridge from UFOs to FontTools objects (and therefore, OTFs and TTFs).
MIT License
151 stars 43 forks source link

[FlattenComponents] Don't throw weird errors when components are missing #669

Closed simoncozens closed 1 year ago

simoncozens commented 1 year ago

If I use fontmake on a Glyphs file which contains components with missing base glyphs, I get errors like this:

INFO:ufo2ft.filters:Running FlattenComponentsFilter on GoogleSans_Persian-Regular
fontmake: Error: In 'master_ufo/XXX-Regular.designspace': Generating fonts from Designspace failed: 'flig2'

(Side note: there are many cases where fontmake eats the original exception like this, and produces weird and inscrutable errors. We should hunt down all of them.)

With this PR, the font compiles with warnings:

WARNING:ufo2ft.filters.flattenComponents:Could not find component 'flig2' used in 'f_f'
simoncozens commented 1 year ago

A second side note is that this happens even in glyphs which are set to non-exporting, which shouldn't happen anyway.

anthrotype commented 1 year ago

Are we sure a WARNING is better than a (probably better phrased) error in this case? A missing component is probably bad and should be caught at build time. Warnings can be ignored.

this happens even in glyphs which are set to non-exporting, which shouldn't happen anyway.

this should be investigated further, because I think preprocessor already takes care of excluding the non-exported glyphs from the glyph set that is passed to the filters, so FlattenComponentsFilter should not even see those..

simoncozens commented 1 year ago

Nope, I'm wrong - I was changing the exported glyphs of a Glyphs file but compiling the intermediate UFO. The glyphset issue is fine, so I'm happy to make this a hard error.