本文整理匯總了Python中robofab.pens.digestPen.DigestPointPen類的典型用法代碼示例。如果您正苦於以下問題:Python DigestPointPen類的具體用法?Python DigestPointPen怎麽用?Python DigestPointPen使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DigestPointPen類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
def __init__(self, glyph, soft=False):
p = DigestPointPen(ignoreSmoothAndName=True)
glyph.drawPoints(p)
self.digest = p.getDigest()
self.glyph = MathGlyph(glyph)
self.t = time.time()
self.name = glyph.name
self.soft = soft
示例2: getDigest
def getDigest(dGlyph):
"""copied from robofab ObjectsBase.py.
"""
mp = DigestPointPen()
dGlyph.drawPoints(mp)
digest = mp.getDigestPointsOnly(needSort=False)
# we need to round to int.
intDigest = digest #[ (int(p[0]), int(p[1])) for p in digest]
return intDigest
示例3: testFabPenCompatibility
def testFabPenCompatibility(self):
for glyph in self.font:
digestPen = DigestPointPen(ignoreSmoothAndName=True)
pen = FabToFontToolsPenAdapter(SegmentToPointPen(digestPen))
glyph.draw(pen)
digest1 = digestPen.getDigest()
digestPen = DigestPointPen(ignoreSmoothAndName=True)
glyph.drawPoints(digestPen)
digest2 = digestPen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same for gl.draw() and gl.drawPoints()" % glyph.name)
示例4: _doTest
def _doTest(self, shapeFunc, shapeName):
pen = DigestPointPen(ignoreSmoothAndName=True)
shapeFunc(pen)
digest1 = pen.getDigest()
digestPen = DigestPointPen(ignoreSmoothAndName=True)
pen = PointToSegmentPen(SegmentToPointPen(digestPen))
shapeFunc(pen)
digest2 = digestPen.getDigest()
self.assertEqual(digest1, digest2, "%r failed round tripping" % shapeName)
示例5: testSegmentPenInterface
def testSegmentPenInterface(self):
for glyph in self.font:
digestPen = DigestPointPen(ignoreSmoothAndName=True)
pen = SegmentToPointPen(digestPen)
glyph.draw(pen)
digest1 = digestPen.getDigest()
digestPen = DigestPointPen(ignoreSmoothAndName=True)
glyph.drawPoints(digestPen)
digest2 = digestPen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same for gl.draw() and gl.drawPoints()" % glyph.name)
示例6: Glyph2String
def Glyph2String(glyph):
from robofab.pens.digestPen import DigestPointPen
import pickle
p = DigestPointPen(glyph)
glyph.drawPoints(p)
info = {}
info['name'] = glyph.name
info['width'] = glyph.width
info['points'] = p.getDigest()
return str(pickle.dumps(info))
示例7: testReversContourFromGlyphSet
def testReversContourFromGlyphSet(self):
glyphSet = GlyphSet(getDemoFontGlyphSetPath())
digestPen = DigestPointPen()
glyphSet["testglyph1"].drawPoints(digestPen)
digest1 = digestPen.getDigest()
digestPen = DigestPointPen()
pen = ReverseContourPointPen(digestPen)
glyphSet["testglyph1.reversed"].drawPoints(pen)
digest2 = digestPen.getDigest()
self.assertEqual(digest1, digest2)
示例8: testGuessSmoothPen
def testGuessSmoothPen(self):
glyphSet = GlyphSet(getDemoFontGlyphSetPath())
for name in glyphSet.keys():
digestPen = DigestPointPen()
glyphSet[name].drawPoints(digestPen)
digest1 = digestPen.getDigest()
digestPen = DigestPointPen()
pen = GuessSmoothPointPen(digestPen)
glyphSet[name].drawPoints(pen)
digest2 = digestPen.getDigest()
self.assertEqual(digest1, digest2)
示例9: testScaleGlyph
def testScaleGlyph(self):
for glyph in self.font:
pen = DigestPointPen()
glyph.drawPoints(pen)
digest1 = pen.getDigest()
glyph.scale((2, 2))
glyph.scale((.5, .5))
pen = DigestPointPen()
glyph.drawPoints(pen)
digest2 = pen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same after scaling twice" % glyph.name)
示例10: testMoveGlyph
def testMoveGlyph(self):
for glyph in self.font:
pen = DigestPointPen()
glyph.drawPoints(pen)
digest1 = pen.getDigest()
glyph.move((100, 200))
glyph.move((-100, -200))
pen = DigestPointPen()
glyph.drawPoints(pen)
digest2 = pen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same after moving twice" % glyph.name)
示例11: testDigestGlyph
def testDigestGlyph(glyph):
from robofab.pens.digestPen import DigestPointPen
pen = DigestPointPen()
glyph.draw(pen)
return (
glyph.name,
glyph.width,
glyph.unicode,
glyph.mark,
glyph.note,
pen.getDigest()
)
示例12: testStartSegment
def testStartSegment(self):
for glyph in self.font:
pen = DigestPointPen()
glyph.drawPoints(pen)
digest1 = pen.getDigest()
for contour in glyph:
contour.setStartSegment(2)
contour.setStartSegment(-2)
pen = DigestPointPen()
glyph.drawPoints(pen)
digest2 = pen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same after seting start segment twice" % glyph.name)
示例13: testAppendSegment
def testAppendSegment(self):
for glyph in self.font:
pen = DigestPointPen()
glyph.drawPoints(pen)
digest1 = pen.getDigest()
for contour in glyph:
contour.insertSegment(2, "curve", [(100, 100), (200, 200), (300, 300)])
contour.removeSegment(2)
pen = DigestPointPen()
glyph.drawPoints(pen)
digest2 = pen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same after inserting and removing segment" % glyph.name)
示例14: testReverseContour
def testReverseContour(self):
for glyph in self.font:
pen = DigestPointPen()
glyph.drawPoints(pen)
digest1 = pen.getDigest()
for contour in glyph:
contour.reverseContour()
contour.reverseContour()
pen = DigestPointPen()
glyph.drawPoints(pen)
digest2 = pen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same after reversing twice" % glyph.name)
示例15: testCopyGlyph
def testCopyGlyph(self):
for glyph in self.font:
pen = DigestPointPen()
glyph.drawPoints(pen)
digest1 = pen.getDigest()
copy = glyph.copy()
pen = DigestPointPen()
copy.drawPoints(pen)
digest2 = pen.getDigest()
self.assertEqual(digest1, digest2, "%r not the same after copying" % glyph.name)
self.assertEqual(glyph.lib, copy.lib, "%r's lib not the same after copying" % glyph.name)
self.assertEqual(glyph.width, copy.width, "%r's width not the same after copying" % glyph.name)
self.assertEqual(glyph.unicodes, copy.unicodes, "%r's unicodes not the same after copying" % glyph.name)