from __future__ import print_function, division, absolute_import from fontTools.misc.py23 import * from fontTools.pens.perimeterPen import PerimeterPen import unittest def draw1_(pen): pen.moveTo( (254, 360) ) pen.lineTo( (771, 367) ) pen.curveTo( (800, 393), (808, 399), (819, 412) ) pen.curveTo( (818, 388), (774, 138), (489, 145) ) pen.curveTo( (188, 145), (200, 398), (200, 421) ) pen.curveTo( (209, 409), (220, 394), (254, 360) ) pen.closePath() def draw2_(pen): pen.moveTo( (254, 360) ) pen.curveTo( (220, 394), (209, 409), (200, 421) ) pen.curveTo( (200, 398), (188, 145), (489, 145) ) pen.curveTo( (774, 138), (818, 388), (819, 412) ) pen.curveTo( (808, 399), (800, 393), (771, 367) ) pen.closePath() def draw3_(pen): pen.moveTo( (771, 367) ) pen.curveTo( (800, 393), (808, 399), (819, 412) ) pen.curveTo( (818, 388), (774, 138), (489, 145) ) pen.curveTo( (188, 145), (200, 398), (200, 421) ) pen.curveTo( (209, 409), (220, 394), (254, 360) ) pen.closePath() def draw4_(pen): pen.moveTo( (771, 367) ) pen.lineTo( (254, 360) ) pen.curveTo( (220, 394), (209, 409), (200, 421) ) pen.curveTo( (200, 398), (188, 145), (489, 145) ) pen.curveTo( (774, 138), (818, 388), (819, 412) ) pen.curveTo( (808, 399), (800, 393), (771, 367) ) pen.closePath() def draw5_(pen): pen.moveTo( (254, 360) ) pen.lineTo( (771, 367) ) pen.qCurveTo( (793, 386), (802, 394) ) pen.qCurveTo( (811, 402), (819, 412) ) pen.qCurveTo( (819, 406), (814, 383.5) ) pen.qCurveTo( (809, 361), (796, 330.5) ) pen.qCurveTo( (783, 300), (760.5, 266.5) ) pen.qCurveTo( (738, 233), (701, 205.5) ) pen.qCurveTo( (664, 178), (612, 160.5) ) pen.qCurveTo( (560, 143), (489, 145) ) pen.qCurveTo( (414, 145), (363, 164) ) pen.qCurveTo( (312, 183), (280, 211.5) ) pen.qCurveTo( (248, 240), (231.5, 274.5) ) pen.qCurveTo( (215, 309), (208, 339.5) ) pen.qCurveTo( (201, 370), (200.5, 392.5) ) pen.qCurveTo( (200, 415), (200, 421) ) pen.qCurveTo( (207, 412), (217.5, 399) ) pen.qCurveTo( (228, 386), (254, 360) ) pen.closePath() def draw6_(pen): pen.moveTo( (254, 360) ) pen.qCurveTo( (228, 386), (217.5, 399) ) pen.qCurveTo( (207, 412), (200, 421) ) pen.qCurveTo( (200, 415), (200.5, 392.5) ) pen.qCurveTo( (201, 370), (208, 339.5) ) pen.qCurveTo( (215, 309), (231.5, 274.5) ) pen.qCurveTo( (248, 240), (280, 211.5) ) pen.qCurveTo( (312, 183), (363, 164) ) pen.qCurveTo( (414, 145), (489, 145) ) pen.qCurveTo( (560, 143), (612, 160.5) ) pen.qCurveTo( (664, 178), (701, 205.5) ) pen.qCurveTo( (738, 233), (760.5, 266.5) ) pen.qCurveTo( (783, 300), (796, 330.5) ) pen.qCurveTo( (809, 361), (814, 383.5) ) pen.qCurveTo( (819, 406), (819, 412) ) pen.qCurveTo( (811, 402), (802, 394) ) pen.qCurveTo( (793, 386), (771, 367) ) pen.closePath() def draw7_(pen): pen.moveTo( (771, 367) ) pen.qCurveTo( (793, 386), (802, 394) ) pen.qCurveTo( (811, 402), (819, 412) ) pen.qCurveTo( (819, 406), (814, 383.5) ) pen.qCurveTo( (809, 361), (796, 330.5) ) pen.qCurveTo( (783, 300), (760.5, 266.5) ) pen.qCurveTo( (738, 233), (701, 205.5) ) pen.qCurveTo( (664, 178), (612, 160.5) ) pen.qCurveTo( (560, 143), (489, 145) ) pen.qCurveTo( (414, 145), (363, 164) ) pen.qCurveTo( (312, 183), (280, 211.5) ) pen.qCurveTo( (248, 240), (231.5, 274.5) ) pen.qCurveTo( (215, 309), (208, 339.5) ) pen.qCurveTo( (201, 370), (200.5, 392.5) ) pen.qCurveTo( (200, 415), (200, 421) ) pen.qCurveTo( (207, 412), (217.5, 399) ) pen.qCurveTo( (228, 386), (254, 360) ) pen.closePath() def draw8_(pen): pen.moveTo( (771, 367) ) pen.lineTo( (254, 360) ) pen.qCurveTo( (228, 386), (217.5, 399) ) pen.qCurveTo( (207, 412), (200, 421) ) pen.qCurveTo( (200, 415), (200.5, 392.5) ) pen.qCurveTo( (201, 370), (208, 339.5) ) pen.qCurveTo( (215, 309), (231.5, 274.5) ) pen.qCurveTo( (248, 240), (280, 211.5) ) pen.qCurveTo( (312, 183), (363, 164) ) pen.qCurveTo( (414, 145), (489, 145) ) pen.qCurveTo( (560, 143), (612, 160.5) ) pen.qCurveTo( (664, 178), (701, 205.5) ) pen.qCurveTo( (738, 233), (760.5, 266.5) ) pen.qCurveTo( (783, 300), (796, 330.5) ) pen.qCurveTo( (809, 361), (814, 383.5) ) pen.qCurveTo( (819, 406), (819, 412) ) pen.qCurveTo( (811, 402), (802, 394) ) pen.qCurveTo( (793, 386), (771, 367) ) pen.closePath() class PerimeterPenTest(unittest.TestCase): def test_PScontour_clockwise_line_first(self): pen = PerimeterPen(None) draw1_(pen) self.assertEqual(1589, round(pen.value)) def test_PScontour_counterclockwise_line_last(self): pen = PerimeterPen(None) draw2_(pen) self.assertEqual(1589, round(pen.value)) def test_PScontour_clockwise_line_last(self): pen = PerimeterPen(None) draw3_(pen) self.assertEqual(1589, round(pen.value)) def test_PScontour_counterclockwise_line_first(self): pen = PerimeterPen(None) draw4_(pen) self.assertEqual(1589, round(pen.value)) def test_TTcontour_clockwise_line_first(self): pen = PerimeterPen(None) draw5_(pen) self.assertEqual(1589, round(pen.value)) def test_TTcontour_counterclockwise_line_last(self): pen = PerimeterPen(None) draw6_(pen) self.assertEqual(1589, round(pen.value)) def test_TTcontour_clockwise_line_last(self): pen = PerimeterPen(None) draw7_(pen) self.assertEqual(1589, round(pen.value)) def test_TTcontour_counterclockwise_line_first(self): pen = PerimeterPen(None) draw8_(pen) self.assertEqual(1589, round(pen.value)) if __name__ == '__main__': import sys sys.exit(unittest.main())