def test_to_ufo_draw_paths_open(self): layer = GSLayer() path = GSPath() path.nodes = [ GSNode(position=(0, 0), nodetype="line"), GSNode(position=(1, 1), nodetype="offcurve"), GSNode(position=(2, 2), nodetype="offcurve"), GSNode(position=(3, 3), nodetype="curve", smooth=True), ] path.closed = False layer.paths.append(path) glyph = _Glyph() to_ufo_paths(_UFOBuilder(), glyph, layer) self.assertEqual( glyph.pen.contours, [ [ (0, 0, "move", False), (1, 1, None, False), (2, 2, None, False), (3, 3, "curve", True), ] ], )
def test_to_ufo_draw_paths_empty_nodes(self): layer = GSLayer() layer.paths.append(GSPath()) glyph = _Glyph() to_ufo_paths(_UFOBuilder(), glyph, layer) self.assertEqual(glyph.pen.contours, [])
def test_to_ufo_draw_paths_qcurve(self): layer = GSLayer() path = GSPath() path.nodes = [ GSNode(position=(143, 695), nodetype="offcurve"), GSNode(position=(37, 593), nodetype="offcurve"), GSNode(position=(37, 434), nodetype="offcurve"), GSNode(position=(143, 334), nodetype="offcurve"), GSNode(position=(223, 334), nodetype="qcurve", smooth=True), ] path.closed = True layer.paths.append(path) glyph = _Glyph() to_ufo_paths(_UFOBuilder(), glyph, layer) points = glyph.pen.contours[0] first_x, first_y = points[0][:2] self.assertEqual((first_x, first_y), (223, 334)) first_segment_type = points[0][2] self.assertEqual(first_segment_type, "qcurve")
def test_to_ufo_draw_paths_closed(self): layer = GSLayer() path = GSPath() path.nodes = [ GSNode(position=(0, 0), nodetype='offcurve'), GSNode(position=(1, 1), nodetype='offcurve'), GSNode(position=(2, 2), nodetype='curve', smooth=True), GSNode(position=(3, 3), nodetype='offcurve'), GSNode(position=(4, 4), nodetype='offcurve'), GSNode(position=(5, 5), nodetype='curve', smooth=True), ] path.closed = True layer.paths.append(path) glyph = _Glyph() to_ufo_paths(_UFOBuilder(), glyph, layer) points = glyph.pen.contours[0] first_x, first_y = points[0][:2] self.assertEqual((first_x, first_y), (5, 5)) first_segment_type = points[0][2] self.assertEqual(first_segment_type, 'curve')