Skip to content
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

fix a bug in dropImpliedOnCurvePoints #3155

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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