[ttGlyphPen_test] test decomposed contours keep original order

This commit is contained in:
Cosimo Lupo 2018-03-01 18:52:55 +00:00
parent 6606bbef3c
commit ede35d72c8
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482

View File

@ -5,7 +5,7 @@ import os
import unittest import unittest
from fontTools import ttLib from fontTools import ttLib
from fontTools.pens.ttGlyphPen import TTGlyphPen from fontTools.pens.ttGlyphPen import TTGlyphPen, MAX_F2DOT14
class TTGlyphPenTest(unittest.TestCase): class TTGlyphPenTest(unittest.TestCase):
@ -135,7 +135,7 @@ class TTGlyphPenTest(unittest.TestCase):
self.assertEqual(len(pen.points), 5) self.assertEqual(len(pen.points), 5)
self.assertEqual(pen.points[0], (0, 0)) self.assertEqual(pen.points[0], (0, 0))
def test_within_range_of_scale_component(self): def test_within_range_component_transform(self):
componentName = 'a' componentName = 'a'
glyphSet = {} glyphSet = {}
pen = TTGlyphPen(glyphSet) pen = TTGlyphPen(glyphSet)
@ -156,7 +156,7 @@ class TTGlyphPenTest(unittest.TestCase):
self.assertEqual(expectedGlyph, compositeGlyph) self.assertEqual(expectedGlyph, compositeGlyph)
def test_limit_of_scale_component(self): def test_clamp_to_almost_2_component_transform(self):
componentName = 'a' componentName = 'a'
glyphSet = {} glyphSet = {}
pen = TTGlyphPen(glyphSet) pen = TTGlyphPen(glyphSet)
@ -174,7 +174,7 @@ class TTGlyphPenTest(unittest.TestCase):
pen.addComponent(componentName, (-2, 0, 0, -2, 0, 0)) pen.addComponent(componentName, (-2, 0, 0, -2, 0, 0))
compositeGlyph = pen.glyph() compositeGlyph = pen.glyph()
almost2 = 1.99993896484375 # 0b1.11111111111111 almost2 = MAX_F2DOT14 # 0b1.11111111111111
pen.addComponent(componentName, (almost2, 0, 0, 1, 0, 0)) pen.addComponent(componentName, (almost2, 0, 0, 1, 0, 0))
pen.addComponent(componentName, (1, almost2, 0, 1, 0, 0)) pen.addComponent(componentName, (1, almost2, 0, 1, 0, 0))
pen.addComponent(componentName, (1, 0, almost2, 1, 0, 0)) pen.addComponent(componentName, (1, 0, almost2, 1, 0, 0))
@ -184,7 +184,7 @@ class TTGlyphPenTest(unittest.TestCase):
self.assertEqual(expectedGlyph, compositeGlyph) self.assertEqual(expectedGlyph, compositeGlyph)
def test_out_of_range_scale_component(self): def test_out_of_range_component_transform(self):
componentName = 'a' componentName = 'a'
glyphSet = {} glyphSet = {}
pen = TTGlyphPen(glyphSet) pen = TTGlyphPen(glyphSet)
@ -196,6 +196,7 @@ class TTGlyphPenTest(unittest.TestCase):
glyphSet[componentName] = _TestGlyph(pen.glyph()) glyphSet[componentName] = _TestGlyph(pen.glyph())
pen.addComponent(componentName, (3, 0, 0, 2, 0, 0)) pen.addComponent(componentName, (3, 0, 0, 2, 0, 0))
pen.addComponent(componentName, (1, 0, 0, 1, -1, 2))
pen.addComponent(componentName, (2, 0, 0, -3, 0, 0)) pen.addComponent(componentName, (2, 0, 0, -3, 0, 0))
compositeGlyph = pen.glyph() compositeGlyph = pen.glyph()
@ -203,6 +204,10 @@ class TTGlyphPenTest(unittest.TestCase):
pen.lineTo((0, 2)) pen.lineTo((0, 2))
pen.lineTo((3, 0)) pen.lineTo((3, 0))
pen.closePath() pen.closePath()
pen.moveTo((-1, 2))
pen.lineTo((-1, 3))
pen.lineTo((0, 2))
pen.closePath()
pen.moveTo((0, 0)) pen.moveTo((0, 0))
pen.lineTo((0, -3)) pen.lineTo((0, -3))
pen.lineTo((2, 0)) pen.lineTo((2, 0))