diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index b88df1b92..fe2a0bb1e 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -1432,7 +1432,8 @@ class GlyphComponent(object): class GlyphCoordinates(object): - def __init__(self, iterable=[], typecode="h"): + def __init__(self, iterable=[], typecode='i'): + if typecode == 'h': typecode = 'i' self._a = array.array(typecode) self.extend(iterable) @@ -1451,9 +1452,6 @@ class GlyphCoordinates(object): def _checkFloat(self, p): if self.isFloat(): return p - if any(v > 0x7FFF or v < -0x8000 for v in p): - self._ensureFloat() - return p if any(isinstance(v, float) for v in p): p = [int(v) if int(v) == v else v for v in p] if any(isinstance(v, float) for v in p): @@ -1508,7 +1506,7 @@ class GlyphCoordinates(object): def toInt(self, *, round=otRound): if not self.isFloat(): return - a = array.array("h") + a = array.array("i") for n in self._a: a.append(round(n)) self._a = a diff --git a/Tests/ttLib/tables/_g_l_y_f_test.py b/Tests/ttLib/tables/_g_l_y_f_test.py index 531bb82aa..70560cc7b 100644 --- a/Tests/ttLib/tables/_g_l_y_f_test.py +++ b/Tests/ttLib/tables/_g_l_y_f_test.py @@ -173,10 +173,9 @@ class GlyphCoordinatesTest(object): assert g[0][0] == otRound(afloat) def test__checkFloat_overflow(self): - g = GlyphCoordinates([(1, 1)], typecode="h") + g = GlyphCoordinates([(1, 1)]) g.append((0x8000, 0)) - assert g.array.typecode == "d" - assert g.array == array.array("d", [1.0, 1.0, 32768.0, 0.0]) + assert list(g.array) == [1.0, 1.0, 32768.0, 0.0] CURR_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))