Skip to content

Commit 6bc5c9b

Browse files
authored
Merge pull request #70 from typemytype/update-tests-for-fonttools-splitCubicAtT-fix
Fix test compatibility with fonttools splitCubicAtT precision improvement
2 parents c83d3bc + 3d8e08e commit 6bc5c9b

File tree

9 files changed

+36
-15
lines changed

9 files changed

+36
-15
lines changed

tests/testData/test.ufo/glyphs.difference/Q_.glif

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<point x="316.25401306152344" y="115.74598693847656" type="line"/>
1717
<point x="296.205190429384" y="105.674005342992"/>
1818
<point x="273.686684" y="100.0"/>
19-
<point x="250.00000000000003" y="100.0" type="curve" smooth="yes"/>
19+
<point x="250.0" y="100.0" type="curve" smooth="yes"/>
2020
<point x="168.0" y="100.0"/>
2121
<point x="100.0" y="168.0"/>
2222
<point x="100.0" y="250.0" type="curve" smooth="yes"/>
@@ -32,7 +32,7 @@
3232
<point x="455.01900482177734" y="106.98099517822266" type="line"/>
3333
<point x="483.36549467244805" y="147.495045593896"/>
3434
<point x="500.00000000000006" y="196.816732"/>
35-
<point x="500.0" y="249.99999999999997" type="curve" smooth="yes"/>
35+
<point x="500.0" y="250.0" type="curve" smooth="yes"/>
3636
<point x="500.0" y="388.0"/>
3737
<point x="388.0" y="500.0"/>
3838
<point x="250.0" y="500.0" type="curve" smooth="yes"/>

tests/testData/test.ufo/glyphs.difference/Q_T_ail_reversed.glif

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<point x="316.26061248779297" y="115.73938751220703" type="line"/>
1717
<point x="296.210179594696" y="105.675262540048"/>
1818
<point x="273.689308" y="100.0"/>
19-
<point x="249.99999999999997" y="100.0" type="curve" smooth="yes"/>
19+
<point x="250.0" y="100.0" type="curve" smooth="yes"/>
2020
<point x="168.0" y="100.0"/>
2121
<point x="100.0" y="168.0"/>
2222
<point x="100.0" y="250.0" type="curve" smooth="yes"/>
@@ -32,7 +32,7 @@
3232
<point x="455.01900482177734" y="106.98099517822266" type="line"/>
3333
<point x="483.36549467244805" y="147.495045593896"/>
3434
<point x="500.00000000000006" y="196.816732"/>
35-
<point x="500.0" y="249.99999999999997" type="curve" smooth="yes"/>
35+
<point x="500.0" y="250.0" type="curve" smooth="yes"/>
3636
<point x="500.0" y="388.0"/>
3737
<point x="388.0" y="500.0"/>
3838
<point x="250.0" y="500.0" type="curve" smooth="yes"/>

tests/testData/test.ufo/glyphs.intersection/Q_.glif

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<point x="382.20357513427734" y="179.79642486572266" type="line"/>
2121
<point x="393.540909595132" y="200.78517673041398"/>
2222
<point x="400.0" y="224.727682"/>
23-
<point x="400.00000000000006" y="250.0" type="curve" smooth="yes"/>
23+
<point x="400.0" y="250.0" type="curve" smooth="yes"/>
2424
<point x="400.0" y="332.0"/>
2525
<point x="332.0" y="400.0"/>
2626
<point x="250.0" y="400.0" type="curve" smooth="yes"/>

tests/testData/test.ufo/glyphs.intersection/Q_T_ail_reversed.glif

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<point x="382.20421600341797" y="179.79578399658203" type="line"/>
2121
<point x="393.541161083068" y="200.78610895348598"/>
2222
<point x="400.0" y="224.72817399999997"/>
23-
<point x="400.0" y="249.99999999999997" type="curve" smooth="yes"/>
23+
<point x="400.0" y="250.0" type="curve" smooth="yes"/>
2424
<point x="400.0" y="332.0"/>
2525
<point x="332.0" y="400.0"/>
2626
<point x="250.0" y="400.0" type="curve" smooth="yes"/>

tests/testData/test.ufo/glyphs.union/Q_.glif

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<point x="455.01900482177734" y="106.98099517822266" type="line"/>
1313
<point x="483.36549467244805" y="147.495045593896"/>
1414
<point x="500.00000000000006" y="196.816732"/>
15-
<point x="500.0" y="249.99999999999997" type="curve" smooth="yes"/>
15+
<point x="500.0" y="250.0" type="curve" smooth="yes"/>
1616
<point x="500.0" y="388.0"/>
1717
<point x="388.0" y="500.0"/>
1818
<point x="250.0" y="500.0" type="curve" smooth="yes"/>
@@ -23,7 +23,7 @@
2323
<point x="112.0" y="0.0"/>
2424
</contour>
2525
<contour>
26-
<point x="250.00000000000003" y="100.0" type="curve" smooth="yes"/>
26+
<point x="250.0" y="100.0" type="curve" smooth="yes"/>
2727
<point x="168.0" y="100.0"/>
2828
<point x="100.0" y="168.0"/>
2929
<point x="100.0" y="250.0" type="curve" smooth="yes"/>

tests/testData/test.ufo/glyphs.union/Q_T_ail_reversed.glif

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<point x="455.01900482177734" y="106.98099517822266" type="line"/>
2121
<point x="483.36549467244805" y="147.495045593896"/>
2222
<point x="500.00000000000006" y="196.816732"/>
23-
<point x="500.0" y="249.99999999999997" type="curve" smooth="yes"/>
23+
<point x="500.0" y="250.0" type="curve" smooth="yes"/>
2424
<point x="500.0" y="388.0"/>
2525
<point x="388.0" y="500.0"/>
2626
<point x="250.0" y="500.0" type="curve" smooth="yes"/>

tests/testData/test.ufo/glyphs.xor/Q_.glif

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<point x="316.25401306152344" y="115.74598693847656" type="line"/>
1717
<point x="296.205190429384" y="105.674005342992"/>
1818
<point x="273.686684" y="100.0"/>
19-
<point x="250.00000000000003" y="100.0" type="curve" smooth="yes"/>
19+
<point x="250.0" y="100.0" type="curve" smooth="yes"/>
2020
<point x="168.0" y="100.0"/>
2121
<point x="100.0" y="168.0"/>
2222
<point x="100.0" y="250.0" type="curve" smooth="yes"/>
@@ -38,7 +38,7 @@
3838
<point x="455.01900482177734" y="106.98099517822266" type="line"/>
3939
<point x="483.36549467244805" y="147.495045593896"/>
4040
<point x="500.00000000000006" y="196.816732"/>
41-
<point x="500.0" y="249.99999999999997" type="curve" smooth="yes"/>
41+
<point x="500.0" y="250.0" type="curve" smooth="yes"/>
4242
<point x="500.0" y="388.0"/>
4343
<point x="388.0" y="500.0"/>
4444
<point x="250.0" y="500.0" type="curve" smooth="yes"/>

tests/testData/test.ufo/glyphs.xor/Q_T_ail_reversed.glif

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<point x="316.26061248779297" y="115.73938751220703" type="line"/>
1717
<point x="296.210179594696" y="105.675262540048"/>
1818
<point x="273.689308" y="100.0"/>
19-
<point x="249.99999999999997" y="100.0" type="curve" smooth="yes"/>
19+
<point x="250.0" y="100.0" type="curve" smooth="yes"/>
2020
<point x="168.0" y="100.0"/>
2121
<point x="100.0" y="168.0"/>
2222
<point x="100.0" y="250.0" type="curve" smooth="yes"/>
@@ -38,7 +38,7 @@
3838
<point x="455.01900482177734" y="106.98099517822266" type="line"/>
3939
<point x="483.36549467244805" y="147.495045593896"/>
4040
<point x="500.00000000000006" y="196.816732"/>
41-
<point x="500.0" y="249.99999999999997" type="curve" smooth="yes"/>
41+
<point x="500.0" y="250.0" type="curve" smooth="yes"/>
4242
<point x="500.0" y="388.0"/>
4343
<point x="388.0" y="500.0"/>
4444
<point x="250.0" y="500.0" type="curve" smooth="yes"/>

tests/test_BooleanGlyph.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import print_function, division, absolute_import
22

3-
import sys
3+
import math
44
import os
5+
import sys
56
import unittest
67

78
import pytest
@@ -14,6 +15,23 @@
1415
VERBOSE = False
1516

1617

18+
def _approx_equal(a, b):
19+
"""Check if two values are approximately equal, handling nested structures.
20+
21+
Uses math.isclose for float comparison to handle minor differences between
22+
fonttools versions in splitCubicAtT precision.
23+
"""
24+
if type(a) != type(b):
25+
return False
26+
if isinstance(a, (tuple, list)):
27+
if len(a) != len(b):
28+
return False
29+
return all(_approx_equal(x, y) for x, y in zip(a, b))
30+
if isinstance(a, float):
31+
return math.isclose(a, b)
32+
return a == b
33+
34+
1735
class BooleanTests(unittest.TestCase):
1836

1937
pass
@@ -47,7 +65,10 @@ def test(self):
4765
func(*args, outPen=testPen)
4866
expectedPen = DigestPointPen()
4967
expectedGlyph.drawPoints(expectedPen)
50-
self.assertEqual(testPen.getDigest(), expectedPen.getDigest(), "Glyph name '%s' failed for '%s'." % (glyph.name, booleanMethodName))
68+
self.assertTrue(
69+
_approx_equal(testPen.getDigest(), expectedPen.getDigest()),
70+
"Glyph name '%s' failed for '%s'." % (glyph.name, booleanMethodName)
71+
)
5172

5273
return True, test
5374

0 commit comments

Comments
 (0)