-
Notifications
You must be signed in to change notification settings - Fork 43
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
filters/featureWriters: use '...' as placeholder for loading from UFO lib #604
Conversation
… lib Currently the `filters` and `featureWriters` parameters 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. Fontmake will also be updated to allow passing --filter='...' or --feature-writer='...' CLI options to use this feature. Part of fixing googlefonts/fontmake#872
only for self-documentation as we don't run static typechecker. there's a lot of duck-typing in ufo2ft.. One day maybe we'll define protocols for Font, Filter, etc.
latest flake8 suddenly started complaining about unrelated stuff like: B020 Found for loop that reassigns the iterable it is iterating with each iterable value. I just fixed these even if they don't belong here, just to make CI go green. Also apparently flake8 cares about undefined names inside `# type: ` comment, I guess that's a feature. Let's see if I can fool it. https://github.com/googlefonts/ufo2ft/runs/5871883161?check_suite_focus=true#step:5:35
for st in st.statements: | ||
for s in feaLib.statements: | ||
if isinstance(s, ast.TableBlock) and s.name == "GDEF": | ||
for st in s.statements: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is unrelated, it was just to appease flake8 complaining about loop variable reassigning the iterable it's iterating on
groups = defaultdict(list) | ||
for node, color in color.items(): | ||
for node, color in colors.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, just to make flake8 happy
/cc @m4rc1e |
Fixes #872 Depends on googlefonts/ufo2ft#604 to be merged/released first
Fixes #872 Depends on googlefonts/ufo2ft#604 to be merged/released first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just had a play with this pr and googlefonts/fontmake#874 (review) in gftools builder and it is working nicely.
Before:
INFO:ufo2ft.filters.base:Running FlattenComponentsFilter on MavenPro-Regular
INFO:ufo2ft.filters.flattenComponents:Flattened composite glyphs: 343
INFO:ufo2ft.filters.base:Running DecomposeTransformedComponentsFilter on MavenPro-Regular
After:
INFO:ufo2ft:Pre-processing glyphs
INFO:ufo2ft.filters.base:Running EraseOpenCornersFilter on MavenPro-Regular
INFO:ufo2ft.filters.base:Running FlattenComponentsFilter on MavenPro-Regular
INFO:ufo2ft.filters.flattenComponents:Flattened composite glyphs: 343
INFO:ufo2ft.filters.base:Running DecomposeTransformedComponentsFilter on MavenPro-Regular
We can see the additional filters are now being executed.
AFAIK I'm happy but I'm not really a maintainer of this repo so if someone else would like to give it the all good, feel free.
Currently the
filters
andfeatureWriters
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 actualEllipsis
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.:
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 googlefonts/fontmake#872