Esempio n. 1
0
 def test_incompatible_glyphs(self, outlines, exception, message):
     glyphs = []
     for i, outline in enumerate(outlines):
         glyph = Glyph()
         glyph.name = "glyph%d" % i
         pen = glyph.getPen()
         for operator, args in outline:
             getattr(pen, operator)(*args)
         glyphs.append(glyph)
     with pytest.raises(exception) as excinfo:
         glyphs_to_quadratic(glyphs)
     assert excinfo.match(message)
Esempio n. 2
0
    def test_overlapping_start_end_points(self):
        # https://github.com/googlefonts/fontmake/issues/572
        glyph1 = Glyph()
        pen = glyph1.getPointPen()
        pen.beginPath()
        pen.addPoint((0, 651), segmentType="line")
        pen.addPoint((0, 101), segmentType="line")
        pen.addPoint((0, 101), segmentType="line")
        pen.addPoint((0, 651), segmentType="line")
        pen.endPath()

        glyph2 = Glyph()
        pen = glyph2.getPointPen()
        pen.beginPath()
        pen.addPoint((1, 651), segmentType="line")
        pen.addPoint((2, 101), segmentType="line")
        pen.addPoint((3, 101), segmentType="line")
        pen.addPoint((4, 651), segmentType="line")
        pen.endPath()

        glyphs = [glyph1, glyph2]

        assert glyphs_to_quadratic(glyphs, reverse_direction=True)

        assert [[(p.x, p.y) for p in glyph[0]] for glyph in glyphs] == [
            [
                (0, 651),
                (0, 651),
                (0, 101),
                (0, 101),
            ],
            [(1, 651), (4, 651), (3, 101), (2, 101)],
        ]
Esempio n. 3
0
 def test_stats(self, fonts):
     stats = {}
     glyphs_to_quadratic([f['a'] for f in fonts], stats=stats)
     assert stats == {'2': 1, '3': 7, '4': 3, '5': 1}
Esempio n. 4
0
 def test_modified(self, fonts, glyph, expected):
     glyphs = [f[glyph] for f in fonts]
     assert glyphs_to_quadratic(glyphs) == expected
Esempio n. 5
0
 def test_reverse_direction(self, fonts):
     glyphs = [f['A'] for f in fonts]
     assert glyphs_to_quadratic(glyphs, reverse_direction=True)
Esempio n. 6
0
 def test_max_err_list(self, fonts):
     glyphs = [f['a'] for f in fonts]
     stats = {}
     glyphs_to_quadratic(glyphs, max_err=[4.096, 4.096], stats=stats)
     assert stats == {'2': 11, '3': 1}