code: def to_ufo_paths(self, ufo_glyph, layer):
      
      pen = ufo_glyph.getPointPen()
  
      for path in layer.paths:
          # the list is changed below, otherwise you can't draw more than once
          # per session.
          nodes = list(path.nodes)
          for node in nodes:
              self.to_ufo_node_user_data(ufo_glyph, node)
  
          pen.beginPath()
          if not nodes:
              pen.endPath()
              continue
          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")
          else:
              # In Glyphs.app, the starting node of a closed contour is always
              # stored at the end of the nodes list.
              nodes.insert(0, nodes.pop())
          for node in nodes:
              node_type = _to_ufo_node_type(node.type)
              pen.addPoint(
                  tuple(node.position), segmentType=node_type, smooth=node.smooth
              )
          pen.endPath()
docs: Draw .glyphs paths onto a pen.