1try: 2 from fontTools.misc.symfont import AreaPen 3except ImportError: 4 AreaPen = None 5import unittest 6import pytest 7 8precision = 6 9 10 11def draw1_(pen): 12 pen.moveTo((254, 360)) 13 pen.lineTo((771, 367)) 14 pen.curveTo((800, 393), (808, 399), (819, 412)) 15 pen.curveTo((818, 388), (774, 138), (489, 145)) 16 pen.curveTo((188, 145), (200, 398), (200, 421)) 17 pen.curveTo((209, 409), (220, 394), (254, 360)) 18 pen.closePath() 19 20 21class AreaPenTest(unittest.TestCase): 22 @pytest.mark.skipif(AreaPen is None, reason="sympy not installed") 23 def test_PScontour_clockwise_line_first(self): 24 pen = AreaPen(glyphset=None) 25 draw1_(pen) 26 self.assertEqual(-104561.35, round(pen.value, precision)) 27 28 @pytest.mark.skipif(AreaPen is None, reason="sympy not installed") 29 def test_openPaths(self): 30 pen = AreaPen() 31 pen.moveTo((0, 0)) 32 pen.endPath() 33 self.assertEqual(0, pen.value) 34 35 pen.moveTo((0, 0)) 36 pen.lineTo((1, 0)) 37 with self.assertRaises(NotImplementedError): 38 pen.endPath() 39 40 41if __name__ == "__main__": 42 import sys 43 44 sys.exit(unittest.main()) 45