remove zero delta tuples from variable font #2830
-
Hi
removing these tuples helps to optimize the file size. glyphs app has I need it as a part of independent build process. maybe it's predicted in fonttools or ttx, or a script(that i couldn't write it). so please help. (I'm not aware of software complexities, but extremely recommend to add it (directly or as an optional stage) to |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
Something like this should do: from fontTools.ttLib import TTFont
import sys
font = TTFont(sys.argv[1])
gvar = font["gvar"]
new_variations = {}
for glyph,variations in gvar.variations.items():
l1 = len(variations)
variations = [v for v in variations
if any(i is None or i[0] or i[1]
for i in v.coordinates)]
l2 = len(variations)
if l1 != l2:
print(glyph, l1, l2)
if variations:
new_variations[glyph] = variations
gvar.variations = new_variations
font.save("out.ttf") |
Beta Was this translation helpful? Give feedback.
-
We already do that: except for composite glyphs as I mentioned. The change that disabled this optimization for composites was: |
Beta Was this translation helpful? Give feedback.
Something like this should do: