def get_digest(digest_glyph): """copied from robofab ObjectsBase.py. """ mp = DigestPointPen() digest_glyph.drawPoints(mp) digest = list(mp.getDigestPointsOnly(needSort=False)) digest.append((len(digest_glyph.contours), 0)) return digest
def test(self): if VERBOSE: print("test: '%s' for '%s'" % (glyph.name, booleanMethodName)) testPen = DigestPointPen() func(*args, outPen=testPen) expectedPen = DigestPointPen() expectedGlyph.drawPoints(expectedPen) self.assertEqual(testPen.getDigest(), expectedPen.getDigest(), "Glyph name '%s' failed for '%s'." % (glyph.name, booleanMethodName))
def testDigestGlyph(glyph): from fontPens.digestPointPen import DigestPointPen pen = DigestPointPen() glyph.drawPoints(pen) return ( glyph.name, glyph.width, glyph.unicode, glyph.markColor, glyph.note, pen.getDigest() )
def test_decompose_digest(self): from fontPens.digestPointPen import DigestPointPen component = self.getComponent_generic() glyph = component.glyph glyph.layer[component.baseGlyph] component.decompose() pointPen = DigestPointPen() glyph.drawPoints(pointPen) expected = (('beginPath', None), ((0, 0), u'line', False, 'point 0'), ((0, 100), u'line', False, 'point 1'), ((100, 100), u'line', False, 'point 2'), ((100, 0), u'line', False, 'point 3'), 'endPath') self.assertEqual(pointPen.getDigest(), expected)
def test_decompose_digest(self): from fontPens.digestPointPen import DigestPointPen component = self.getComponent_generic() glyph = component.glyph glyph.layer[component.baseGlyph] component.decompose() pointPen = DigestPointPen() glyph.drawPoints(pointPen) expected = ( ('beginPath', None), ((0, 0), u'line', False, 'point 0'), ((0, 100), u'line', False, 'point 1'), ((100, 100), u'line', False, 'point 2'), ((100, 0), u'line', False, 'point 3'), 'endPath' ) self.assertEqual( pointPen.getDigest(), expected )