Skip to content

remove zero delta tuples from variable font #2830

Answered by behdad
aminabedi68 asked this question in Q&A
Discussion options

You must be logged in to vote

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")

Replies: 2 comments 14 replies

Comment options

You must be logged in to vote
13 replies
@aminabedi68
Comment options

@aminabedi68
Comment options

@behdad
Comment options

@behdad
Comment options

@aminabedi68
Comment options

Answer selected by aminabedi68
Comment options

You must be logged in to vote
1 reply
@aminabedi68
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants