[ttGlyphPen] Rename preserveTopology to dropImpliedOnCurves

This commit is contained in:
Behdad Esfahbod 2023-02-22 09:08:39 -07:00
parent b916c4cdae
commit 8f89a435ac
2 changed files with 14 additions and 9 deletions

View File

@ -170,9 +170,14 @@ class _TTGlyphBasePen:
components.append(component) components.append(component)
return components return components
def glyph(self, componentFlags: int = 0x4, preserveTopology=True) -> Glyph: def glyph(self, componentFlags: int = 0x04, dropImpliedOnCurves=False) -> Glyph:
""" """
Returns a :py:class:`~._g_l_y_f.Glyph` object representing the glyph. Returns a :py:class:`~._g_l_y_f.Glyph` object representing the glyph.
Args:
componentFlags: Flags to use for component glyphs. (default: 0x04)
dropImpliedOnCurves: Whether to remove implied-oncurve points. (default: False)
""" """
if not self._isClosed(): if not self._isClosed():
raise PenError("Didn't close last contour.") raise PenError("Didn't close last contour.")
@ -184,7 +189,7 @@ class _TTGlyphBasePen:
glyph.flags = array("B", self.types) glyph.flags = array("B", self.types)
glyph.coordinates.toInt() glyph.coordinates.toInt()
if not preserveTopology: if dropImpliedOnCurves:
drop_implied_oncurves(glyph) drop_implied_oncurves(glyph)
self.init() self.init()

View File

@ -639,10 +639,10 @@ class CubicGlyfTest:
] ]
@pytest.mark.parametrize( @pytest.mark.parametrize(
"preserveTopology, segment_pen_commands, point_pen_commands, expected_coordinates, expected_flags, expected_endPts", "dropImpliedOnCurves, segment_pen_commands, point_pen_commands, expected_coordinates, expected_flags, expected_endPts",
[ [
( # Two curves that do NOT merge; request merging ( # Two curves that do NOT merge; request merging
False, True,
[ [
("moveTo", ((0, 0),)), ("moveTo", ((0, 0),)),
("curveTo", ((0, 1), (1, 2), (2, 2))), ("curveTo", ((0, 1), (1, 2), (2, 2))),
@ -665,7 +665,7 @@ class CubicGlyfTest:
[6], [6],
), ),
( # Two curves that merge; request merging ( # Two curves that merge; request merging
False, True,
[ [
("moveTo", ((0, 0),)), ("moveTo", ((0, 0),)),
("curveTo", ((0, 1), (1, 2), (2, 2))), ("curveTo", ((0, 1), (1, 2), (2, 2))),
@ -688,7 +688,7 @@ class CubicGlyfTest:
[5], [5],
), ),
( # Two curves that merge; request NOT merging ( # Two curves that merge; request NOT merging
True, False,
[ [
("moveTo", ((0, 0),)), ("moveTo", ((0, 0),)),
("curveTo", ((0, 1), (1, 2), (2, 2))), ("curveTo", ((0, 1), (1, 2), (2, 2))),
@ -711,7 +711,7 @@ class CubicGlyfTest:
[6], [6],
), ),
( # Two (duplicate) contours ( # Two (duplicate) contours
False, True,
[ [
("moveTo", ((0, 0),)), ("moveTo", ((0, 0),)),
("curveTo", ((0, 1), (1, 2), (2, 2))), ("curveTo", ((0, 1), (1, 2), (2, 2))),
@ -776,7 +776,7 @@ class CubicGlyfTest:
) )
def test_cubic_topology( def test_cubic_topology(
self, self,
preserveTopology, dropImpliedOnCurves,
segment_pen_commands, segment_pen_commands,
point_pen_commands, point_pen_commands,
expected_coordinates, expected_coordinates,
@ -795,7 +795,7 @@ class CubicGlyfTest:
for pen in (spen, ppen): for pen in (spen, ppen):
glyph = pen.glyph(preserveTopology=preserveTopology) glyph = pen.glyph(dropImpliedOnCurves=dropImpliedOnCurves)
assert list(glyph.coordinates) == expected_coordinates assert list(glyph.coordinates) == expected_coordinates
assert list(glyph.flags) == expected_flags assert list(glyph.flags) == expected_flags