summaryrefslogtreecommitdiff
path: root/misc/pylib/robofab/test/test_objectsFL.py
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2017-09-04 06:03:17 +0300
committerRasmus Andersson <rasmus@notion.se>2017-09-04 18:12:34 +0300
commit8234b62ab762637ef24c3398b4204a8ce8db31a7 (patch)
tree1c8df547021cdb58951630a015e4101ede46dbf1 /misc/pylib/robofab/test/test_objectsFL.py
parent31ae014e0c827dd76696fdab7e4ca3fed9f6402b (diff)
downloadinter-8234b62ab762637ef24c3398b4204a8ce8db31a7.tar.xz
Speeds up font compilation by around 200%
Cython is used to compile some hot paths into native Python extensions. These hot paths were identified through running ufocompile with the hotshot profiler and then converting file by file to Cython, starting with the "hottest" paths and continuing until returns were deminishing. This means that only a few Python files were converted to Cython. Closes #23 Closes #20 (really this time)
Diffstat (limited to 'misc/pylib/robofab/test/test_objectsFL.py')
-rwxr-xr-xmisc/pylib/robofab/test/test_objectsFL.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/misc/pylib/robofab/test/test_objectsFL.py b/misc/pylib/robofab/test/test_objectsFL.py
new file mode 100755
index 000000000..948897097
--- /dev/null
+++ b/misc/pylib/robofab/test/test_objectsFL.py
@@ -0,0 +1,54 @@
+"""This test suite for various FontLab-specific tests."""
+
+
+import FL # needed to quickly raise ImportError if run outside of FL
+
+
+import os
+import tempfile
+import unittest
+
+from robofab.world import NewFont
+from robofab.test.testSupport import getDemoFontPath, getDemoFontGlyphSetPath
+from robofab.tools.glifImport import importAllGlifFiles
+from robofab.pens.digestPen import DigestPointPen
+from robofab.pens.adapterPens import SegmentToPointPen
+
+
+def getDigests(font):
+ digests = {}
+ for glyphName in font.keys():
+ pen = DigestPointPen()
+ font[glyphName].drawPoints(pen)
+ digests[glyphName] = pen.getDigest()
+ return digests
+
+
+class FLTestCase(unittest.TestCase):
+
+ def testUFOVersusGlifImport(self):
+ font = NewFont()
+ font.readUFO(getDemoFontPath(), doProgress=False)
+ d1 = getDigests(font)
+ font.close(False)
+ font = NewFont()
+ importAllGlifFiles(font.naked(), getDemoFontGlyphSetPath(), doProgress=False)
+ d2 = getDigests(font)
+ self.assertEqual(d1, d2)
+ font.close(False)
+
+ def testTwoUntitledFonts(self):
+ font1 = NewFont()
+ font2 = NewFont()
+ font1.unitsPerEm = 1024
+ font2.unitsPerEm = 2048
+ self.assertNotEqual(font1.unitsPerEm, font2.unitsPerEm)
+ font1.update()
+ font2.update()
+ font1.close(False)
+ font2.close(False)
+
+
+if __name__ == "__main__":
+ from robofab.test.testSupport import runTests
+ runTests()