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

Support writing the final autogenerated feature file somewhere #353

Closed
madig opened this issue Nov 22, 2019 · 5 comments · Fixed by #354
Closed

Support writing the final autogenerated feature file somewhere #353

madig opened this issue Nov 22, 2019 · 5 comments · Fixed by #354

Comments

@madig
Copy link
Collaborator

madig commented Nov 22, 2019

Useful for debugging. Maybe a new parameter on all compile* functions that is a IOBuffer that the feature file is written to. Then fontmake can be wired up to pass something in.

@madig madig changed the title Support writing the final autogenerated featuire file somewhere Support writing the final autogenerated feature file somewhere Nov 22, 2019
@typoman
Copy link

typoman commented Nov 22, 2019

I was wondering how the feature generator could be used as a separate package. The mark and kern feature generators are very useful. Also the way ufo2ft uses subsetting to infer pseudo unicodes could be used elsewhere in designing fonts.

@madig
Copy link
Collaborator Author

madig commented Nov 22, 2019

You can call into ufo2ft directly. See e.g. the tests for what to do.

@anthrotype
Copy link
Member

anthrotype commented Nov 22, 2019

@typoman you can do like this

from ufo2ft.featureCompiler import parseLayoutFeatures
from ufo2ft.featureWriters import KernFeatureWriter
from ufoLib2 import Font

# if you want to append to an existing features.fea, you must parse it first
font = Font.open("MyFont.ufo")
featureFile = parseLayoutFeatures(font)

# alternatively you can pass a new empty FeatureFile object
# from fontTools.feaLib.ast import FeatureFile
# featureFile = FeatureFile()

kernWriter = KernFeatureWriter()  # you may select the mode or pass options here
kernWriter.write(font, featureFile)
feaText = featureFile.asFea()

print(feaText)

@typoman
Copy link

typoman commented Nov 22, 2019

Thank you very much!

@anthrotype
Copy link
Member

@typoman I updated the code, the first iteration was incorrect

anthrotype added a commit to anthrotype/ufo2ft that referenced this issue Nov 22, 2019
and forward it from all the other compile* functions.

It dumps the content of the features to a TextIO for debugging.

Fixes googlefonts#353
anthrotype added a commit to anthrotype/ufo2ft that referenced this issue Nov 22, 2019
and forward it from all the other compile* functions.

It dumps the content of the features to a TextIO for debugging.

Fixes googlefonts#353
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 a pull request may close this issue.

3 participants