[ttGlyphPen] Rename preserveTopology to dropImpliedOnCurves
This commit is contained in:
parent
b916c4cdae
commit
8f89a435ac
@ -170,9 +170,14 @@ class _TTGlyphBasePen:
|
||||
components.append(component)
|
||||
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.
|
||||
|
||||
Args:
|
||||
componentFlags: Flags to use for component glyphs. (default: 0x04)
|
||||
|
||||
dropImpliedOnCurves: Whether to remove implied-oncurve points. (default: False)
|
||||
"""
|
||||
if not self._isClosed():
|
||||
raise PenError("Didn't close last contour.")
|
||||
@ -184,7 +189,7 @@ class _TTGlyphBasePen:
|
||||
glyph.flags = array("B", self.types)
|
||||
|
||||
glyph.coordinates.toInt()
|
||||
if not preserveTopology:
|
||||
if dropImpliedOnCurves:
|
||||
drop_implied_oncurves(glyph)
|
||||
|
||||
self.init()
|
||||
|
@ -639,10 +639,10 @@ class CubicGlyfTest:
|
||||
]
|
||||
|
||||
@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
|
||||
False,
|
||||
True,
|
||||
[
|
||||
("moveTo", ((0, 0),)),
|
||||
("curveTo", ((0, 1), (1, 2), (2, 2))),
|
||||
@ -665,7 +665,7 @@ class CubicGlyfTest:
|
||||
[6],
|
||||
),
|
||||
( # Two curves that merge; request merging
|
||||
False,
|
||||
True,
|
||||
[
|
||||
("moveTo", ((0, 0),)),
|
||||
("curveTo", ((0, 1), (1, 2), (2, 2))),
|
||||
@ -688,7 +688,7 @@ class CubicGlyfTest:
|
||||
[5],
|
||||
),
|
||||
( # Two curves that merge; request NOT merging
|
||||
True,
|
||||
False,
|
||||
[
|
||||
("moveTo", ((0, 0),)),
|
||||
("curveTo", ((0, 1), (1, 2), (2, 2))),
|
||||
@ -711,7 +711,7 @@ class CubicGlyfTest:
|
||||
[6],
|
||||
),
|
||||
( # Two (duplicate) contours
|
||||
False,
|
||||
True,
|
||||
[
|
||||
("moveTo", ((0, 0),)),
|
||||
("curveTo", ((0, 1), (1, 2), (2, 2))),
|
||||
@ -776,7 +776,7 @@ class CubicGlyfTest:
|
||||
)
|
||||
def test_cubic_topology(
|
||||
self,
|
||||
preserveTopology,
|
||||
dropImpliedOnCurves,
|
||||
segment_pen_commands,
|
||||
point_pen_commands,
|
||||
expected_coordinates,
|
||||
@ -795,7 +795,7 @@ class CubicGlyfTest:
|
||||
|
||||
for pen in (spen, ppen):
|
||||
|
||||
glyph = pen.glyph(preserveTopology=preserveTopology)
|
||||
glyph = pen.glyph(dropImpliedOnCurves=dropImpliedOnCurves)
|
||||
|
||||
assert list(glyph.coordinates) == expected_coordinates
|
||||
assert list(glyph.flags) == expected_flags
|
||||
|
Loading…
x
Reference in New Issue
Block a user