Skip to content

Commit

Permalink
Merge pull request #3155 from fonttools/fix-drop-implied-oncurves
Browse files Browse the repository at this point in the history
fix a bug in dropImpliedOnCurvePoints
  • Loading branch information
anthrotype committed Jun 6, 2023
2 parents 6559819 + 0761508 commit 66ce7c0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions Lib/fontTools/ttLib/tables/_g_l_y_f.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,7 @@ def dropImpliedOnCurvePoints(*interpolatable_glyphs: Glyph) -> Set[int]:
continue

may_drop.add(i)
start = last + 1
# we only want to drop if ALL interpolatable glyphs have the same implied oncurves
if drop is None:
drop = may_drop
Expand Down
35 changes: 29 additions & 6 deletions Tests/ttLib/tables/_g_l_y_f_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,20 +856,43 @@ def test_dropImpliedOnCurvePoints_all_quad_off_curves():
((-1, -1), 0),
((-1, 0), flagOnCurve),
((-1, 1), 0),
]
],
[
((0, 2), flagOnCurve),
((2, 2), 0),
((2, 0), flagOnCurve),
((2, -2), 0),
((0, -2), flagOnCurve),
((-2, -2), 0),
((-2, 0), flagOnCurve),
((-2, 2), 0),
],
],
Transform().scale(2.0),
)
# also add an empty glyph (will be ignored); we use this trick for 'sparse' masters
glyph3 = Glyph()
glyph3.numberOfContours = 0

assert dropImpliedOnCurvePoints(glyph1, glyph2, glyph3) == {0, 2, 4, 6}
assert dropImpliedOnCurvePoints(glyph1, glyph2, glyph3) == {
0,
2,
4,
6,
8,
10,
12,
14,
}

assert glyph1.flags == glyph2.flags == array.array("B", [0, 0, 0, 0])
assert glyph1.coordinates == GlyphCoordinates([(1, 1), (1, -1), (-1, -1), (-1, 1)])
assert glyph2.coordinates == GlyphCoordinates([(2, 2), (2, -2), (-2, -2), (-2, 2)])
assert glyph1.endPtsOfContours == glyph2.endPtsOfContours == [3]
assert glyph1.flags == glyph2.flags == array.array("B", [0, 0, 0, 0, 0, 0, 0, 0])
assert glyph1.coordinates == GlyphCoordinates(
[(1, 1), (1, -1), (-1, -1), (-1, 1), (2, 2), (2, -2), (-2, -2), (-2, 2)]
)
assert glyph2.coordinates == GlyphCoordinates(
[(2, 2), (2, -2), (-2, -2), (-2, 2), (4, 4), (4, -4), (-4, -4), (-4, 4)]
)
assert glyph1.endPtsOfContours == glyph2.endPtsOfContours == [3, 7]
assert glyph3.numberOfContours == 0


Expand Down

0 comments on commit 66ce7c0

Please sign in to comment.