本文整理匯總了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)
],
]