本文整理汇总了Python中fontTools.pens.ttGlyphPen.TTGlyphPen.moveTo方法的典型用法代码示例。如果您正苦于以下问题:Python TTGlyphPen.moveTo方法的具体用法?Python TTGlyphPen.moveTo怎么用?Python TTGlyphPen.moveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fontTools.pens.ttGlyphPen.TTGlyphPen
的用法示例。
在下文中一共展示了TTGlyphPen.moveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clamp_to_almost_2_component_transform
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_clamp_to_almost_2_component_transform(self):
componentName = 'a'
glyphSet = {}
pen = TTGlyphPen(glyphSet)
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
glyphSet[componentName] = _TestGlyph(pen.glyph())
pen.addComponent(componentName, (1.99999, 0, 0, 1, 0, 0))
pen.addComponent(componentName, (1, 2, 0, 1, 0, 0))
pen.addComponent(componentName, (1, 0, 2, 1, 0, 0))
pen.addComponent(componentName, (1, 0, 0, 2, 0, 0))
pen.addComponent(componentName, (-2, 0, 0, -2, 0, 0))
compositeGlyph = pen.glyph()
almost2 = MAX_F2DOT14 # 0b1.11111111111111
pen.addComponent(componentName, (almost2, 0, 0, 1, 0, 0))
pen.addComponent(componentName, (1, almost2, 0, 1, 0, 0))
pen.addComponent(componentName, (1, 0, almost2, 1, 0, 0))
pen.addComponent(componentName, (1, 0, 0, almost2, 0, 0))
pen.addComponent(componentName, (-2, 0, 0, -2, 0, 0))
expectedGlyph = pen.glyph()
self.assertEqual(expectedGlyph, compositeGlyph)
示例2: test_closePath_ignoresAnchors
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_closePath_ignoresAnchors(self):
pen = TTGlyphPen(None)
pen.moveTo((0, 0))
pen.closePath()
self.assertFalse(pen.points)
self.assertFalse(pen.types)
self.assertFalse(pen.endPts)
示例3: test_build_var
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_build_var(tmpdir):
outPath = os.path.join(str(tmpdir), "test_var.ttf")
fb, advanceWidths, nameStrings = _setupFontBuilder(True)
pen = TTGlyphPen(None)
pen.moveTo((100, 0))
pen.lineTo((100, 400))
pen.lineTo((500, 400))
pen.lineTo((500, 000))
pen.closePath()
glyph = pen.glyph()
pen = TTGlyphPen(None)
emptyGlyph = pen.glyph()
glyphs = {".notdef": emptyGlyph, "A": glyph, "a": glyph, ".null": emptyGlyph}
fb.setupGlyf(glyphs)
metrics = {}
glyphTable = fb.font["glyf"]
for gn, advanceWidth in advanceWidths.items():
metrics[gn] = (advanceWidth, glyphTable[gn].xMin)
fb.setupHorizontalMetrics(metrics)
fb.setupHorizontalHeader(ascent=824, descent=200)
fb.setupNameTable(nameStrings)
axes = [
('LEFT', 0, 0, 100, "Left"),
('RGHT', 0, 0, 100, "Right"),
('UPPP', 0, 0, 100, "Up"),
('DOWN', 0, 0, 100, "Down"),
]
instances = [
dict(location=dict(LEFT=0, RGHT=0, UPPP=0, DOWN=0), stylename="TotallyNormal"),
dict(location=dict(LEFT=0, RGHT=100, UPPP=100, DOWN=0), stylename="Right Up"),
]
fb.setupFvar(axes, instances)
variations = {}
# Four (x, y) pairs and four phantom points:
leftDeltas = [(-200, 0), (-200, 0), (0, 0), (0, 0), None, None, None, None]
rightDeltas = [(0, 0), (0, 0), (200, 0), (200, 0), None, None, None, None]
upDeltas = [(0, 0), (0, 200), (0, 200), (0, 0), None, None, None, None]
downDeltas = [(0, -200), (0, 0), (0, 0), (0, -200), None, None, None, None]
variations['a'] = [
TupleVariation(dict(RGHT=(0, 1, 1)), rightDeltas),
TupleVariation(dict(LEFT=(0, 1, 1)), leftDeltas),
TupleVariation(dict(UPPP=(0, 1, 1)), upDeltas),
TupleVariation(dict(DOWN=(0, 1, 1)), downDeltas),
]
fb.setupGvar(variations)
fb.setupOS2()
fb.setupPost()
fb.setupDummyDSIG()
fb.save(outPath)
_verifyOutput(outPath)
示例4: test_remove_extra_move_points
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_remove_extra_move_points(self):
pen = TTGlyphPen(None)
pen.moveTo((0, 0))
pen.lineTo((100, 0))
pen.qCurveTo((100, 50), (50, 100), (0, 0))
pen.closePath()
self.assertEqual(len(pen.points), 4)
self.assertEqual(pen.points[0], (0, 0))
示例5: test_keep_duplicate_end_point
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_keep_duplicate_end_point(self):
pen = TTGlyphPen(None)
pen.moveTo((0, 0))
pen.lineTo((100, 0))
pen.qCurveTo((100, 50), (50, 100), (0, 0))
pen.lineTo((0, 0)) # the duplicate point is not removed
pen.closePath()
self.assertEqual(len(pen.points), 5)
self.assertEqual(pen.points[0], (0, 0))
示例6: test_keep_move_point
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_keep_move_point(self):
pen = TTGlyphPen(None)
pen.moveTo((0, 0))
pen.lineTo((100, 0))
pen.qCurveTo((100, 50), (50, 100), (30, 30))
# when last and move pts are different, closePath() implies a lineTo
pen.closePath()
self.assertEqual(len(pen.points), 5)
self.assertEqual(pen.points[0], (0, 0))
示例7: test_glyph_decomposes
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_glyph_decomposes(self):
componentName = 'a'
glyphSet = {}
pen = TTGlyphPen(glyphSet)
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
glyphSet[componentName] = _TestGlyph(pen.glyph())
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
pen.addComponent(componentName, (1, 0, 0, 1, 2, 0))
compositeGlyph = pen.glyph()
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
pen.moveTo((2, 0))
pen.lineTo((2, 1))
pen.lineTo((3, 0))
pen.closePath()
plainGlyph = pen.glyph()
self.assertEqual(plainGlyph, compositeGlyph)
示例8: test_out_of_range_transform_decomposed
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_out_of_range_transform_decomposed(self):
componentName = 'a'
glyphSet = {}
pen = TTGlyphPen(glyphSet)
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
glyphSet[componentName] = _TestGlyph(pen.glyph())
pen.addComponent(componentName, (3, 0, 0, 2, 0, 0))
pen.addComponent(componentName, (1, 0, 0, 1, -1, 2))
pen.addComponent(componentName, (2, 0, 0, -3, 0, 0))
compositeGlyph = pen.glyph()
pen.moveTo((0, 0))
pen.lineTo((0, 2))
pen.lineTo((3, 0))
pen.closePath()
pen.moveTo((-1, 2))
pen.lineTo((-1, 3))
pen.lineTo((0, 2))
pen.closePath()
pen.moveTo((0, 0))
pen.lineTo((0, -3))
pen.lineTo((2, 0))
pen.closePath()
expectedGlyph = pen.glyph()
self.assertEqual(expectedGlyph, compositeGlyph)
示例9: test_endPath_sameAsClosePath
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_endPath_sameAsClosePath(self):
pen = TTGlyphPen(None)
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
closePathGlyph = pen.glyph()
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.endPath()
endPathGlyph = pen.glyph()
self.assertEqual(closePathGlyph, endPathGlyph)
示例10: makeCollectionHmtxTransform2
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def makeCollectionHmtxTransform2():
fonts = [getTTFont(sfntTTFSourcePath), getTTFont(sfntTTFSourcePath)]
for i, font in enumerate(fonts):
glyf = font["glyf"]
hmtx = font["hmtx"]
maxp = font["maxp"]
for name in glyf.glyphs:
glyph = glyf.glyphs[name]
glyph.expand(glyf)
if hasattr(glyph, "xMin"):
metrics = hmtx.metrics[name]
if i == 0:
# Move the glyph so that xMin is 0
pen = TTGlyphPen(None)
glyph.draw(pen, glyf, -glyph.xMin)
glyph = pen.glyph()
glyph.recalcBounds(glyf)
assert glyph.xMin == 0
glyf.glyphs[name] = glyph
hmtx.metrics[name] = (metrics[0], 0)
# Build a unique glyph for each font, but with the same advance and LSB
name = "box"
pen = TTGlyphPen(None)
pen.moveTo([0, 0])
pen.lineTo([0, 1000])
if i > 0:
pen.lineTo([0, 2000])
pen.lineTo([1000, 2000])
pen.lineTo([1000, 1000])
pen.lineTo([1000, 0])
pen.closePath()
glyph = pen.glyph()
glyph.recalcBounds(glyf)
glyf.glyphs[name] = glyph
hmtx.metrics[name] = (glyph.xMax, glyph.xMin)
glyf.glyphOrder.append(name)
maxp.recalc(font)
data = hmtx.compile(font)
hmtx.decompile(data, font)
data = getSFNTCollectionData(fonts, shared=["hmtx"])
return data
示例11: test_no_handle_overflowing_transform
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_no_handle_overflowing_transform(self):
componentName = 'a'
glyphSet = {}
pen = TTGlyphPen(glyphSet, handleOverflowingTransforms=False)
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
baseGlyph = pen.glyph()
glyphSet[componentName] = _TestGlyph(baseGlyph)
pen.addComponent(componentName, (3, 0, 0, 1, 0, 0))
compositeGlyph = pen.glyph()
self.assertEqual(compositeGlyph.components[0].transform,
((3, 0), (0, 1)))
with self.assertRaises(struct.error):
compositeGlyph.compile({'a': baseGlyph})
示例12: test_within_range_component_transform
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_within_range_component_transform(self):
componentName = 'a'
glyphSet = {}
pen = TTGlyphPen(glyphSet)
pen.moveTo((0, 0))
pen.lineTo((0, 1))
pen.lineTo((1, 0))
pen.closePath()
glyphSet[componentName] = _TestGlyph(pen.glyph())
pen.addComponent(componentName, (1.5, 0, 0, 1, 0, 0))
pen.addComponent(componentName, (1, 0, 0, -1.5, 0, 0))
compositeGlyph = pen.glyph()
pen.addComponent(componentName, (1.5, 0, 0, 1, 0, 0))
pen.addComponent(componentName, (1, 0, 0, -1.5, 0, 0))
expectedGlyph = pen.glyph()
self.assertEqual(expectedGlyph, compositeGlyph)
示例13: makeGlyfBBox1
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def makeGlyfBBox1(calcBBoxes=True, composite=False):
font = getTTFont(sfntTTFSourcePath, recalcBBoxes=calcBBoxes)
glyf = font["glyf"]
hmtx = font["hmtx"]
for name in ("bbox1", "bbox2"):
pen = TTGlyphPen(None)
if name == "bbox1":
pen.moveTo((0, 0))
pen.lineTo((0, 1000))
pen.lineTo((1000, 1000))
pen.lineTo((1000, 0))
pen.closePath()
else:
pen.moveTo((0, 0))
pen.qCurveTo((500, 750), (600, 500), (500, 250), (0, 0))
pen.closePath()
glyph = pen.glyph()
if not calcBBoxes:
glyph.recalcBounds(glyf)
glyph.xMax -= 100
glyf.glyphs[name] = glyph
hmtx.metrics[name] = (0, 0)
glyf.glyphOrder.append(name)
if composite:
name = "bbox3"
pen = TTGlyphPen(glyf.glyphOrder)
pen.addComponent("bbox1", [1, 0, 0, 1, 0, 0])
pen.addComponent("bbox2", [1, 0, 0, 1, 1000, 0])
glyph = pen.glyph()
glyph.recalcBounds(glyf)
glyf.glyphs[name] = glyph
hmtx.metrics[name] = (0, 0)
glyf.glyphOrder.append(name)
tableData = getSFNTData(font)[0]
font.close()
del font
header, directory, tableData = defaultSFNTTestData(tableData=tableData, flavor="TTF")
data = packSFNT(header, directory, tableData, flavor="TTF")
return data
示例14: test_glyph_errorOnUnendedContour
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_glyph_errorOnUnendedContour(self):
pen = TTGlyphPen(None)
pen.moveTo((0, 0))
with self.assertRaises(AssertionError):
pen.glyph()
示例15: test_moveTo_errorWithinContour
# 需要导入模块: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 别名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import moveTo [as 别名]
def test_moveTo_errorWithinContour(self):
pen = TTGlyphPen(None)
pen.moveTo((0, 0))
with self.assertRaises(AssertionError):
pen.moveTo((1, 0))