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

Run filter from CLI #470

Merged
merged 6 commits into from
Mar 1, 2021
Merged

Conversation

simoncozens
Copy link
Contributor

@simoncozens simoncozens commented Feb 26, 2021

This allows the user to run a ufo2ft filter (or filters) on a UFO file and save it from the command line. This is helpful for testing and debugging filters, as well as doing general filter-based operations on fonts.

$ python3 -m ufo2ft.filters ../glyphsLib/master_ufo/Nunito-M1000.ufo glyphsLib.filters.eraseOpenCorners
INFO:ufo2ft.filters:Running EraseOpenCornersFilter on Nunito-M1000
INFO:ufo2ft.filters:Written on ../glyphsLib/master_ufo/Nunito-M1000#1.ufo

Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very useful, thanks!

if not args.output:
args.output = makeOutputFileName(args.ufo)

ufo = defcon.Font(args.ufo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mind switching to ufoLib2 instead? or try ufoLib2 then defcon then ImportError

@moyogo
Copy link
Collaborator

moyogo commented Feb 26, 2021

You can use loadFilterFromString() now that #466 has been merged.

@anthrotype
Copy link
Member

You can use loadFilterFromString() now that #466 has been merged.

good point, yes please

@moyogo
Copy link
Collaborator

moyogo commented Mar 1, 2021

LGTM

@anthrotype anthrotype merged commit 742b3a5 into googlefonts:master Mar 1, 2021
@anthrotype
Copy link
Member

I modified this slightly to set the include/exclude attribute on the filter instance after it has been initialized from the CLI string, this way we can support initializing the filter not only using the filter class name but also with optional keyword arguments

$ python -m ufo2ft.filters tests/data/TestFont.ufo 'CubicToQuadraticFilter(reverseDirection=False)'

d15836d

anthrotype added a commit that referenced this pull request Mar 1, 2021
similar to #470 but for featureWriters. Also useful for testing/debugging.
anthrotype added a commit that referenced this pull request Mar 1, 2021
similar to #470 but for featureWriters. Also useful for testing/debugging.
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 this pull request may close these issues.

3 participants