[TTGlyphPen] Add a test using existing test data
This commit is contained in:
parent
fa82fcd213
commit
943d258bdb
38
Lib/fontTools/pens/ttGlyphPen_test.py
Normal file
38
Lib/fontTools/pens/ttGlyphPen_test.py
Normal file
@ -0,0 +1,38 @@
|
||||
from __future__ import print_function, division, absolute_import
|
||||
from fontTools.misc.py23 import *
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from fontTools import ttLib
|
||||
from fontTools.pens.ttGlyphPen import TTGlyphPen
|
||||
|
||||
|
||||
class TTGlyphPenTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
#self.font = ttLib.TTFont(recalcBBoxes=False, recalcTimestamp=False)
|
||||
self.font = ttLib.TTFont()
|
||||
ttx_path = os.path.join(
|
||||
os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
|
||||
'..', 'ttLib', 'testdata', 'TestTTF-Regular.ttx')
|
||||
self.font.importXML(ttx_path, quiet=True)
|
||||
self.pen = TTGlyphPen(self.font.getGlyphSet())
|
||||
|
||||
def test_drawGlyphsUnchanged(self):
|
||||
glyphSet = self.font.getGlyphSet()
|
||||
glyfTable = self.font['glyf']
|
||||
|
||||
for name in self.font.getGlyphOrder():
|
||||
oldGlyph = glyphSet[name]
|
||||
oldGlyph.draw(self.pen)
|
||||
oldGlyph = oldGlyph._glyph
|
||||
newGlyph = self.pen.glyph()
|
||||
newGlyph.recalcBounds(glyfTable)
|
||||
if hasattr(oldGlyph, 'program'):
|
||||
newGlyph.program = oldGlyph.program
|
||||
self.assertEqual(
|
||||
oldGlyph.compile(glyfTable), newGlyph.compile(glyfTable))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user