make drop_implied_oncurves work with multiple interpolatable glyphs

This commit is contained in:
Cosimo Lupo 2023-05-23 18:20:58 +01:00
parent 02a063685f
commit a73abc6b87
No known key found for this signature in database
GPG Key ID: DF65A8A5A119C9A8

View File

@ -17,8 +17,10 @@ import math
__all__ = ["TTGlyphPen", "TTGlyphPointPen"] __all__ = ["TTGlyphPen", "TTGlyphPointPen"]
def drop_implied_oncurves(glyph): def drop_implied_oncurves(*interpolatable_glyphs):
drop = set() drop = None
for glyph in interpolatable_glyphs:
may_drop = set()
start = 0 start = 0
flags = glyph.flags flags = glyph.flags
coords = glyph.coordinates coords = glyph.coordinates
@ -38,9 +40,16 @@ def drop_implied_oncurves(glyph):
): ):
continue continue
drop.add(i) may_drop.add(i)
# we only want to drop if ALL interpolatable glyphs have the same implied oncurves
if drop is None:
drop = may_drop
else:
drop.intersection_update(may_drop)
if drop: if drop:
# Do the actual dropping # Do the actual dropping
for glyph in interpolatable_glyphs:
glyph.coordinates = GlyphCoordinates( glyph.coordinates = GlyphCoordinates(
coords[i] for i in range(len(coords)) if i not in drop coords[i] for i in range(len(coords)) if i not in drop
) )