Tests: adjust to use new otRound function
This commit is contained in:
parent
d570fc038a
commit
0337fc92fc
@ -142,14 +142,14 @@ class T2CharStringPenTest(unittest.TestCase):
|
||||
pen = T2CharStringPen(100.1, {}, roundTolerance=0.5)
|
||||
pen.moveTo((0, 0))
|
||||
pen.curveTo((10.1, 0.1), (19.9, 9.9), (20.49, 20.49))
|
||||
pen.curveTo((20.49, 30.49), (9.9, 39.9), (0.1, 40.1))
|
||||
pen.curveTo((20.49, 30.5), (9.9, 39.9), (0.1, 40.1))
|
||||
pen.closePath()
|
||||
charstring = pen.getCharString(None, None)
|
||||
|
||||
self.assertEqual(
|
||||
[100,
|
||||
0, 'hmoveto',
|
||||
10, 10, 10, 10, 10, -10, 10, -10, 'hvcurveto',
|
||||
10, 10, 10, 10, 11, -10, 9, -10, 'hvcurveto',
|
||||
'endchar'],
|
||||
charstring.program)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from __future__ import print_function, division, absolute_import
|
||||
from fontTools.misc.py23 import *
|
||||
from fontTools.misc.fixedTools import otRound
|
||||
from fontTools.ttLib.tables._g_l_y_f import GlyphCoordinates
|
||||
import sys
|
||||
import array
|
||||
@ -56,7 +57,7 @@ class GlyphCoordinatesTest(object):
|
||||
def test__round__(self):
|
||||
g = GlyphCoordinates([(-1.5,2)])
|
||||
g2 = round(g)
|
||||
assert g2 == GlyphCoordinates([(-2,2)])
|
||||
assert g2 == GlyphCoordinates([(-1,2)])
|
||||
|
||||
def test__add__(self):
|
||||
g1 = GlyphCoordinates([(1,2)])
|
||||
@ -150,7 +151,7 @@ class GlyphCoordinatesTest(object):
|
||||
# this would return 242 if the internal array.array typecode is 'f',
|
||||
# since the Python float is truncated to a C float.
|
||||
# when using typecode 'd' it should return the correct value 243
|
||||
assert g[0][0] == round(afloat)
|
||||
assert g[0][0] == otRound(afloat)
|
||||
|
||||
def test__checkFloat_overflow(self):
|
||||
g = GlyphCoordinates([(1, 1)], typecode="h")
|
||||
|
@ -164,14 +164,14 @@ class HmtxTableTest(unittest.TestCase):
|
||||
font = self.makeFont(numGlyphs=3, numberOfMetrics=2)
|
||||
mtxTable = font[self.tag] = newTable(self.tag)
|
||||
mtxTable.metrics = {
|
||||
'A': (0.5, 0.5), # round -> (0, 0)
|
||||
'A': (0.5, 0.5), # round -> (1, 1)
|
||||
'B': (0.1, 0.9), # round -> (0, 1)
|
||||
'C': (0.1, 0.1), # round -> (0, 0)
|
||||
}
|
||||
|
||||
data = mtxTable.compile(font)
|
||||
|
||||
self.assertEqual(data, deHexStr("0000 0000 0000 0001 0000"))
|
||||
self.assertEqual(data, deHexStr("0001 0001 0000 0001 0000"))
|
||||
|
||||
def test_toXML(self):
|
||||
font = self.makeFont(numGlyphs=2, numberOfMetrics=2)
|
||||
|
@ -38,7 +38,7 @@
|
||||
<Glyph value="A"/>
|
||||
</Coverage>
|
||||
<ValueFormat value="5"/>
|
||||
<Value XPlacement="-88" XAdvance="-178"/>
|
||||
<Value XPlacement="-88" XAdvance="-177"/>
|
||||
</SinglePos>
|
||||
</Lookup>
|
||||
</LookupList>
|
||||
|
@ -40,8 +40,8 @@
|
||||
</Coverage>
|
||||
<ValueFormat value="5"/>
|
||||
<!-- ValueCount=2 -->
|
||||
<Value index="0" XPlacement="-88" XAdvance="-178"/>
|
||||
<Value index="1" XPlacement="-28" XAdvance="-52"/>
|
||||
<Value index="0" XPlacement="-88" XAdvance="-177"/>
|
||||
<Value index="1" XPlacement="-27" XAdvance="-52"/>
|
||||
</SinglePos>
|
||||
</Lookup>
|
||||
</LookupList>
|
||||
|
@ -41,11 +41,11 @@
|
||||
<EntryExitRecord index="0">
|
||||
<EntryAnchor Format="1">
|
||||
<XCoordinate value="49"/>
|
||||
<YCoordinate value="28"/>
|
||||
<YCoordinate value="29"/>
|
||||
</EntryAnchor>
|
||||
<ExitAnchor Format="1">
|
||||
<XCoordinate value="444"/>
|
||||
<YCoordinate value="294"/>
|
||||
<YCoordinate value="295"/>
|
||||
</ExitAnchor>
|
||||
</EntryExitRecord>
|
||||
</CursivePos>
|
||||
|
@ -55,7 +55,7 @@
|
||||
<!-- BaseCount=1 -->
|
||||
<BaseRecord index="0">
|
||||
<BaseAnchor index="0" Format="1">
|
||||
<XCoordinate value="272"/>
|
||||
<XCoordinate value="273"/>
|
||||
<YCoordinate value="510"/>
|
||||
</BaseAnchor>
|
||||
</BaseRecord>
|
||||
|
@ -56,7 +56,7 @@
|
||||
<Mark2Record index="0">
|
||||
<Mark2Anchor index="0" Format="1">
|
||||
<XCoordinate value="0"/>
|
||||
<YCoordinate value="702"/>
|
||||
<YCoordinate value="703"/>
|
||||
</Mark2Anchor>
|
||||
</Mark2Record>
|
||||
</Mark2Array>
|
||||
|
@ -75,7 +75,7 @@
|
||||
<!-- BaseCount=1 -->
|
||||
<BaseRecord index="0">
|
||||
<BaseAnchor index="0" Format="1">
|
||||
<XCoordinate value="272"/>
|
||||
<XCoordinate value="273"/>
|
||||
<YCoordinate value="510"/>
|
||||
</BaseAnchor>
|
||||
</BaseRecord>
|
||||
|
Loading…
x
Reference in New Issue
Block a user