googlefonts / ufo2ft

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

filters/featureWriters: use '...' as placeholder for loading from UFO lib #604

Closed anthrotype closed 2 years ago

anthrotype commented 2 years ago

Currently the filters and featureWriters parameters always override the ones defined in the UFO lib.plist, and it's impossible to extend instead of replace these, e.g. inserting some additional filter or writer either before or after.

This PR allows to pass a special value ... (the actual Ellipsis singleton, not the str literal '...') in both these lists, which acts as a placeholder to signal one wants to extend the list of predefined filters/writers.

E.g.:

filters=[..., DecomposeTransformedComponentsFilter(pre=True)]

The ellipsis is replaced by the custom filters defined in the UFO lib (if any), and the additional one is appended to the list. Only one ellipsis is allowed in the list. Same for the featureWriters.

Fontmake will also be updated to allow passing --filter='...' or --feature-writer='...' CLI options to use this feature.

Part of fixing https://github.com/googlefonts/fontmake/issues/872

anthrotype commented 2 years ago

/cc @m4rc1e