本文整理汇总了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))
示例2: setUp
# 需要导入模块: import defcon [as 别名]
# 或者: from defcon import Glyph [as 别名]
def setUp(self):
testGlyph = Glyph()
pen = testGlyph.getPen()
self.drawTestGlyph(pen)
self.testGlyph = testGlyph
示例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)
示例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)
示例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)
示例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)
示例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"
示例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
示例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)
],
]