-
Notifications
You must be signed in to change notification settings - Fork 93
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
New instantiator #555
New instantiator #555
Conversation
This is great, thanks! Why is it in fontmake though, shouldn't it be in ufo2ft or somewhere lower? |
@anthrotype and me want to test drive it in fontmake first (I use it for Cantarell already) and maintaining an external lib is extra admin. Fontmake should be the ideal temporary home, as it is a self-contained app hat should not be used as a library. The thinking is, we want to merge ufoLib2 into fontTools.ufoLib.objects one day, reimplement fontMath on those objects and then we figure out where to stick this code. I think. |
I need some more tests that test rounding on vs. off (maybe even against cutting an instance from a VF to ensure that static instances and VF instances are as close as possible if not identical?) and rules. Anything else? How to test axis mappings more? Also:
Edit: just realized that maybe the skipping of empty source glyphs exists to support |
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 is not a full review
about those "muted" attributes for source kerning, info and glyphs, what are they used for? I don't know how widely used they are in the wild, but varLib doesn't read them when generating varfonts. |
maybe once public.verticalOrigin is upgraded to a proper item in the next version of UFO, we can add support for that too Not sure about postscript hints. Were they expected to be interpolated in the mutatormath workflow? Can be done later, I guess |
6e81392
to
f97ba88
Compare
(Idea to self: fill in PANOSE weight field from wght axis maybe) Edit: the weights listed in https://monotype.github.io/panose/pan2.htm#_Toc380547249 differ from the weight class, so there seems to be no 1:1 correlation of OS/2 weight class and PANOSE weight, so maybe don't do it. |
a60e103
to
e56bc65
Compare
f4338ed
to
8d61a00
Compare
Regarding "muted" attributes, shall we remove them to match what varLib does? Makes sense from that standpoint. Plus, they can be added back in I guess. |
I somehow managed to kill instantiator.py while rebasing. Hope I didn't loose anything. |
I am wondering:
|
Not sure I missed something by reducing the component remapping to one loop. |
I think I only need some rounding tests now. Or is there anything else missing? Edit: oh yeah, refactor |
Do we need more sanity checking in the
|
The following code def test_interpolation_against_vf(data_dir):
designspace = designspaceLib.DesignSpaceDocument.fromfile(
data_dir / "MutatorSans" / "MutatorSans-weight-only.designspace"
)
designspace.rules = []
designspace.loadSourceFonts(ufoLib2.Font.open)
designspace.instances[0].location = {"weight": 123.456}
# Generate VF and VF instance.
vf_designspace = ufo2ft.compileInterpolatableTTFsFromDS(designspace, inplace=False)
varfont, _, _ = fontTools.varLib.build(vf_designspace)
varinstance = fontTools.varLib.mutator.instantiateVariableFont(
varfont, {"wght": 123.456}
)
# varfont.save("/tmp/vf.ttf")
varinstance.save("/tmp/vfinstance.ttf")
# Generate instance.
generator = fontmake.instantiator.Instantiator.from_designspace(
designspace, round_geometry=True
)
instance_ufo = generator.generate_instance(designspace.instances[0])
instance = ufo2ft.compileTTF(instance_ufo, removeOverlaps=False)
instance.save("/tmp/instance.ttf") Does not write identical TTFs. Some diffs in e.g. Edit: although... setting or commenting out |
Todo: add handling of |
TestSubset.glyphs or glyphsLib's handling of it is broken. The axis definition comes out as
Which trips varLib. |
Lib/fontmake/font_project.py
Outdated
|
||
assert ( | ||
instance.filename is not None | ||
), "FIXME: Make fontmake not rely on instance filenames" |
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.
what do you mean "not rely on instance filenames"? how does fontmake know where to save the instances if requested to generate them?
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.
My concern is what happens if filename
is not specified.
Note to self: explore Python libraries like Dask and https://pypi.org/project/joblib/ to generate instances in parallel for maximum room heating. |
Interesting performance benefit of Instantiator: Fontmaking NotoSansHebrew-MM.designspace instances takes ~60 seconds on my Ryzen 1700, doing it with Instantiator takes ~20 seconds. Don't know why, but I like it. |
e39ec45
to
034ff06
Compare
Deepcopying the default source's lib is much slower than iterating over it and assigning key and value to the new dict, but I suppose we have to to make the data independent? |
Designspace loading needs to be refactored. I'd like to sanity-check instance filenames so the code doesn't overwrite sources with instances because the filenames are the same (this has happened to me before) and make sure all instances actually have filenames so I don't have to make one up on the spot when saving instances. Fail fast and early. The |
Idea: with the optimization detailed above, the |
Idea: pare down core MutatorMath code and bundle it up for use in |
Hm. Copying things is tricky. If the Designspace object passed into Also, to be fully immutable, we need to turn all Edit: decided that we don't care about independence from the input, but the generated output should be independent. |
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.
haven't finished reviewing, but looking good so far, will continue later or tomorrow
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.
added some more comments
More elegantly deal with missing instance filenames Simply require instance filenames
nice work @madig 👏 |
Build on top of the test rework to add an instantiator to (eventually) replace MutatorMath.
Todo:
slnt
axis (like forwght
andwdth
) which translates 1:1 to post.italicAngle, with clamping.public.skipExportGlyphs
that do not interpolate? Write out as empty outlines and warn, but don't error out.Deferred: