diff --git a/Lib/glyphsLib/builder/paths.py b/Lib/glyphsLib/builder/paths.py index 89a369367..e2bc3942c 100644 --- a/Lib/glyphsLib/builder/paths.py +++ b/Lib/glyphsLib/builder/paths.py @@ -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. diff --git a/Lib/glyphsLib/classes.py b/Lib/glyphsLib/classes.py index b502cfcd2..fd1a676e1 100755 --- a/Lib/glyphsLib/classes.py +++ b/Lib/glyphsLib/classes.py @@ -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. diff --git a/tests/pen_test.py b/tests/pen_test.py index e5fec7de1..e8d1d599f 100644 --- a/tests/pen_test.py +++ b/tests/pen_test.py @@ -113,7 +113,7 @@ 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": {}}), @@ -121,11 +121,11 @@ def test_pointpen_recording(datadir): ("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": {}}),