当前位置: 首页>>代码示例>>Python>>正文


Python defcon.Glyph方法代码示例

本文整理汇总了Python中defcon.Glyph方法的典型用法代码示例。如果您正苦于以下问题:Python defcon.Glyph方法的具体用法?Python defcon.Glyph怎么用?Python defcon.Glyph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在defcon的用法示例。


在下文中一共展示了defcon.Glyph方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_shape_diffs

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def find_shape_diffs(self):
        """Report differences in glyph shapes, using BooleanOperations."""

        self.build_names()

        area_pen = GlyphAreaPen(None)
        pen = PointToSegmentPen(area_pen)
        mismatched = {}
        for name in self.names:
            glyph_a = Glyph()
            glyph_b = Glyph()
            self.glyph_set_a[name].draw(Qu2CuPen(glyph_a.getPen(), self.glyph_set_a))
            self.glyph_set_b[name].draw(Qu2CuPen(glyph_b.getPen(), self.glyph_set_b))
            booleanOperations.xor(list(glyph_a), list(glyph_b), pen)
            area = abs(area_pen.pop())
            if area:
                mismatched[name] = area

        stats = self.stats["compared"]
        for name, area in mismatched.items():
            stats.append((area, name, self.basepath)) 
开发者ID:googlefonts,项目名称:nototools,代码行数:23,代码来源:shape_diff.py

示例2: setUp

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def setUp(self):
                testGlyph = Glyph()
                pen = testGlyph.getPen()
                self.drawTestGlyph(pen)
                self.testGlyph = testGlyph 
开发者ID:loicsander,项目名称:Robofont-scripts,代码行数:7,代码来源:glyphFilter.py

示例3: test_extract_scaled_glyph_as_Defcon_Glyph

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def test_extract_scaled_glyph_as_Defcon_Glyph(self):
            """Test scaled glyph retrieval as a Defcon glyph."""
            from defcon import Glyph
            for testFont in [self.smallFont, self.stemedSmallFont]:
                scaledGlyph = Glyph()
                for glyphName in self.glyphNames:
                    testFont.extractGlyph(glyphName, scaledGlyph)
                    self.assertIsInstance(scaledGlyph, Glyph)
                    self.assertEqual(scaledGlyph.name, glyphName) 
开发者ID:loicsander,项目名称:Robofont-scripts,代码行数:11,代码来源:fonts.py

示例4: test_extract_scaled_glyph_as_Robofab_Glyph

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def test_extract_scaled_glyph_as_Robofab_Glyph(self):
            """Test scaled glyph retrieval as a Robofab Glyph."""
            from robofab.world import RGlyph
            for testFont in [self.smallFont, self.stemedSmallFont]:
                scaledGlyph = RGlyph()
                for glyphName in self.glyphNames:
                    testFont.extractGlyph(glyphName, scaledGlyph)
                    self.assertIsInstance(scaledGlyph, RGlyph) 
开发者ID:loicsander,项目名称:Robofont-scripts,代码行数:10,代码来源:fonts.py

示例5: test_incompatible_glyphs

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
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) 
开发者ID:googlefonts,项目名称:cu2qu,代码行数:14,代码来源:ufo_test.py

示例6: test_already_quadratic

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def test_already_quadratic(self):
        glyph = Glyph()
        pen = glyph.getPen()
        pen.moveTo((0, 0))
        pen.qCurveTo((1, 1), (2, 2))
        pen.closePath()
        assert not glyph_to_quadratic(glyph) 
开发者ID:googlefonts,项目名称:cu2qu,代码行数:9,代码来源:ufo_test.py

示例7: test_open_paths

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def test_open_paths(self):
        glyph = Glyph()
        pen = glyph.getPen()
        pen.moveTo((0, 0))
        pen.lineTo((1, 1))
        pen.curveTo((2, 2), (3, 3), (4, 4))
        pen.endPath()
        assert glyph_to_quadratic(glyph)
        # open contour is still open
        assert glyph[-1][0].segmentType == "move" 
开发者ID:googlefonts,项目名称:cu2qu,代码行数:12,代码来源:ufo_test.py

示例8: test_ignore_components

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def test_ignore_components(self):
        glyph = Glyph()
        pen = glyph.getPen()
        pen.addComponent('a', (1, 0, 0, 1, 0, 0))
        pen.moveTo((0, 0))
        pen.curveTo((1, 1), (2, 2), (3, 3))
        pen.closePath()
        assert glyph_to_quadratic(glyph)
        assert len(glyph.components) == 1 
开发者ID:googlefonts,项目名称:cu2qu,代码行数:11,代码来源:ufo_test.py

示例9: test_overlapping_start_end_points

# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
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)
            ],
        ] 
开发者ID:googlefonts,项目名称:cu2qu,代码行数:40,代码来源:ufo_test.py


注:本文中的defcon.Glyph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。