-
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
Avoid "reloading" TTFonts in PostProcessor.__init__ #485
Comments
One thing the postprocessor does is rename the glyphs to production names. It's very hard to do this without a save/load, because internally to fonttools, glyphs are referred to by name, not by GID. If you change |
Argh. That's what I'm running into locally... So, what do? |
yes, what Simon said. |
maybe the postprocessor should only do the reloading if it's going to actually rename glyphs, not unconditionally like now |
There's a few other things that happen, I'll push a branch. |
Renaming glyphs is such a misunderstood op. One can build a font, make sure all tables are compiled, then do the renaming glyphs, which would involve just loading and saving the post table... |
Or should even be possible to provide the rename mapping at load time. |
So, a lot of this would be a non-issue if we were dealing with immutable data types, such that any modification would involve copy-on-write duplication... Many functional languages work that way. In Python, I'm sure there's some dark black magic with metaclasses to get some of that, but there will be dragons. Also, there's no way to get compile-time errors for violations with Python. Anyway, attrs2 on this: https://www.attrs.org/en/stable/examples.html#immutability |
I'd take some immutability, but the issues I'm seeing are data normalization (e.g. post.italicAngle of 0.0 does not get normalized to 0 like when reloading), data sorting (e.g. name table being in a different order) and glyph names staying as they are 😐 |
I see. |
So, what do? Ideally the compilation pass spits out something that we don't need to reload to make it mergable. Or we reload as little as possible? Any insights appreciated over at #486. |
Yes, I'm happy to work on making that reality.
Okay great. That gives me a point to start. Let's continue there. |
So, going from #486, I stumbled over the following when reloading strictly only for renaming or post version changes:
Doing in the following in the middle of # Sort the name table in case varLib added new entries.
if "name" in self.otf:
self.otf["name"].names.sort()
if "maxp" in self.otf:
self.otf["maxp"].compile(self.otf)
if "STAT" in self.otf:
data = self.otf["STAT"].compile(self.otf)
self.otf["STAT"].decompile(data, self.otf)
if "post" in self.otf and self.otf["post"].formatType == 2.0:
self.otf["post"].extraNames = []
self.otf["post"].compile(self.otf) |
We should completely remove |
Just make the STAT builder set it. The Count values in all of otData are also redundant and could be removed if we are willing to take the breakage and update code depending on it. |
Yes, please! It always seemed odd to have a separate Count field when the data is stored in a Python list anyway. |
I feel like a fonttools API break is gaining support... |
Would this conflict with fT's ability to carry and serialize meaningless/wrong input data in loaded fonts or is it sufficiently high level that that makes little sense? Is that even a design goal? |
These |
The count values are always ignored when compiling the font.
Nope. We don't even pretend.
Or replace them with properties that warn when accessed; set a deadline for removing them, and advise code to switch. The replacement code can even be offered in the warning. |
Fixes #485 For the tests to pass we need to release fonttools with fonttools/fonttools#2860
Fixes #485 For the tests to pass we need to release fonttools with fonttools/fonttools#2860
Going from fonttools/fonttools#1095, quite some time is spent serializing/deserializing fonts somewhere inbetween compiling the final binary. This slows down the entire process.
PostProcessor.__init__
seems to "reload" every font, maybe to clean up loose data? I think it should maybe just work with what it's given?The text was updated successfully, but these errors were encountered: