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

Implement public.skipExportGlyphs handling to exclude glyphs from final font #318

Merged
merged 14 commits into from
Mar 14, 2019
Merged

Implement public.skipExportGlyphs handling to exclude glyphs from final font #318

merged 14 commits into from
Mar 14, 2019

Conversation

madig
Copy link
Collaborator

@madig madig commented Mar 7, 2019

Implement unified-font-object/ufo-spec#68 (comment).

The idea is that we want functionality like Glyphs' "Export" flag on glyphs, giving the designer control over what ends up in the final font file. The crucial difference to fontmake's subsetting functionality is that removing non-export glyphs is done before they reach the actual compiler -- this allows e.g. the exclusion of non-compatible glyphs in the early stages of variable font work, which would otherwise crash the compiler. If the non-export glyphs are used as components, just those components will be decomposed, which matches Glyphs' behavior.

This PR adds handling of a public.skipExportGlyphs lib key on two levels:

  • The compile* functions that take one or more UFOs take a new skipExportGlyphs parameter, which is a list or set of glyph names to be excluded from the final font file. If the parameter is not explicitly passed in, the UFO(s) public.skipExportGlyphs lib key(s) will be consulted. In the case of multiple UFOs, the union of all those lib keys is used. If the UFOs do not have such a key, all glyphs are exported.
  • The compile*FromDS functions that take a Designspace also take a new skipExportGlyphs parameter, which is also a list or set of glyph names to be excluded from the final font file. If the parameter is not explicitly passed in, the Designspace's public.skipExportGlyphs lib key is consulted. If the Designspace does not have such a key, all glyphs are exported (the keys in the UFOs are ignored).

The feature file is not touched. If you reference glyphs that are excluded, the feature compiler will crash.

TODO:

  • How to handle groups and kerning that reference skipped glyphs? Prune them of all skipped glyph names.

@madig madig requested a review from anthrotype March 7, 2019 12:07
@anthrotype
Copy link
Member

Thanks, I’ll take a look soon. What about the feature file?

@anthrotype
Copy link
Member

@madig
Copy link
Collaborator Author

madig commented Mar 7, 2019

Feature file subsetting would need your proposed feaLib changes. Probably not worth hacking something up here.

@anthrotype
Copy link
Member

I wonder if Glyphs.app subsets the feature file for non-Export glyphs?

@madig
Copy link
Collaborator Author

madig commented Mar 7, 2019

In a test file, I have to go to the features pane and hit refresh for Glyphs to add previously non-exported glyphs 🤔

@anthrotype
Copy link
Member

Did you sneakingly run black to reformat everything? Why did init module changed?

@madig
Copy link
Collaborator Author

madig commented Mar 7, 2019

Argh! That was by accident. And I just realized I didn't finish the documentation for the groups/kerning pruning.

Edit: Yet another CRLF -> LF thing. Grrrr!

@madig
Copy link
Collaborator Author

madig commented Mar 7, 2019

(Glyphs does not seem to automatically subset the feature file, you have to update the code.)

Lib/ufo2ft/util.py Outdated Show resolved Hide resolved
@madig
Copy link
Collaborator Author

madig commented Mar 8, 2019

Specification PR at unified-font-object/ufo-spec#84.

Lib/ufo2ft/__init__.py Outdated Show resolved Hide resolved
@anthrotype
Copy link
Member

what about, instead of modifying the groups/kerning in place, we pass the skipExportGlyphs list to the feature compiler so that the filtering is applied only when the feature writers access the groups/kerning from the input UFO, thus without needing to modify the input UFO?

@anthrotype anthrotype closed this Mar 11, 2019
@anthrotype anthrotype reopened this Mar 11, 2019
@anthrotype
Copy link
Member

sorry didn't mean to close the PR

@madig
Copy link
Collaborator Author

madig commented Mar 11, 2019

Hm. That might be a better idea because we don't have to copy anything to avoid source object modification.

@madig madig merged commit f70099a into googlefonts:master Mar 14, 2019
@madig madig deleted the skip-export-glyphs branch March 14, 2019 20:30
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.

2 participants