Skip to content

Commit

Permalink
Merge pull request #790 from justvanrossum/fix-issue789
Browse files Browse the repository at this point in the history
Fix for #789: don't drop 'name' attribute of first point of open contour when drawing to pen
  • Loading branch information
anthrotype authored Jul 4, 2022
2 parents 6d4aba6 + ec2d0ae commit 97642ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Lib/glyphsLib/builder/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def to_ufo_paths(self, ufo_glyph, layer):
if not path.closed:
node = nodes.pop(0)
assert node.type == "line", "Open path starts with off-curve points"
pen.addPoint(tuple(node.position), segmentType="move")
pen.addPoint(
tuple(node.position),
segmentType="move",
name=node.userData.get("name"),
)
else:
# In Glyphs.app, the starting node of a closed contour is always
# stored at the end of the nodes list.
Expand Down
9 changes: 8 additions & 1 deletion Lib/glyphsLib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,14 @@ def drawPoints(self, pointPen: AbstractPointPen) -> None:
if not self.closed:
node = nodes.pop(0)
assert node.type == "line", "Open path starts with off-curve points"
pointPen.addPoint(tuple(node.position), segmentType="move")
node_data = dict(node.userData)
node_name = node_data.pop("name", None)
pointPen.addPoint(
tuple(node.position),
segmentType="move",
name=node_name,
userData=node_data,
)
else:
# In Glyphs.app, the starting node of a closed contour is always
# stored at the end of the nodes list.
Expand Down
6 changes: 3 additions & 3 deletions tests/pen_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ def test_pointpen_recording(datadir):
("addPoint", ((319, 0), None, False, None), {"userData": {}}),
("endPath", (), {}),
("beginPath", (), {}),
("addPoint", ((64, 255), "move", False, None), {}),
("addPoint", ((64, 255), "move", False, None), {"userData": {}}),
("addPoint", ((56, 419), "line", False, None), {"userData": {}}),
("addPoint", ((186, 415), "line", False, None), {"userData": {}}),
("addPoint", ((189, 387), None, False, None), {"userData": {}}),
("addPoint", ((118, 295), None, False, None), {"userData": {}}),
("addPoint", ((196, 331), "curve", False, None), {"userData": {}}),
("endPath", (), {}),
("beginPath", (), {}),
("addPoint", ((266, 285), "move", False, None), {}),
("addPoint", ((266, 285), "move", False, None), {"userData": {}}),
("addPoint", ((412, 421), "line", False, None), {"userData": {}}),
("endPath", (), {}),
("beginPath", (), {}),
("addPoint", ((462, 387), "move", False, None), {}),
("addPoint", ((462, 387), "move", False, None), {"userData": {}}),
("addPoint", ((458, 358), None, False, None), {"userData": {}}),
("addPoint", ((514, 295), None, False, None), {"userData": {}}),
("addPoint", ((450, 301), "curve", False, None), {"userData": {}}),
Expand Down

0 comments on commit 97642ea

Please sign in to comment.