Example #1
0
    def test_to_ufo_draw_paths_empty_nodes(self):
        contours = [GSPath()]

        pen = _PointDataPen()
        to_ufo_draw_paths(None, pen, contours)

        self.assertEqual(pen.contours, [])
Example #2
0
    def test_to_ufo_draw_paths_open(self):
        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
        pen = _PointDataPen()
        to_ufo_draw_paths(None, pen, [path])

        self.assertEqual(pen.contours, [[
            (0, 0, 'move', False),
            (1, 1, None, False),
            (2, 2, None, False),
            (3, 3, 'curve', True),
        ]])
Example #3
0
    def test_to_ufo_draw_paths_qcurve(self):
        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

        pen = _PointDataPen()
        to_ufo_draw_paths(None, pen, [path])

        points = 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')
Example #4
0
    def test_to_ufo_draw_paths_closed(self):
        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

        pen = _PointDataPen()
        to_ufo_draw_paths(None, pen, [path])

        points = 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')