Created
June 10, 2016 22:46
-
-
Save miguelsousa/2a3537bf22d0d739382a996385ed605a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import print_function, division, absolute_import | |
| from fontTools.misc.py23 import * | |
| from fontTools.pens.areaPen import AreaPen | |
| import unittest | |
| # TODO: paths with qCurveTo | |
| precision = 6 | |
| 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() | |
| class AreaPenTest(unittest.TestCase): | |
| def test_draw1(self): | |
| pen = AreaPen(None) | |
| draw1_(pen) | |
| self.assertEqual(104561.35, round(pen.value, precision)) | |
| def test_draw2(self): | |
| pen = AreaPen(None) | |
| draw2_(pen) | |
| self.assertEqual(-104561.35, round(pen.value, precision)) | |
| def test_draw3(self): | |
| pen = AreaPen(None) | |
| draw3_(pen) | |
| self.assertEqual(104561.35, round(pen.value, precision)) | |
| def test_draw4(self): | |
| pen = AreaPen(None) | |
| draw4_(pen) | |
| self.assertEqual(-104561.35, round(pen.value, precision)) | |
| if __name__ == '__main__': | |
| unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment