[glyf] Add round=otRound parameter to GlyphCoordinates.toInt() & __round__()

This commit is contained in:
Behdad Esfahbod 2021-03-04 09:31:15 -07:00
parent 68004b8fec
commit 606b072f40

View File

@ -1506,12 +1506,12 @@ class GlyphCoordinates(object):
p = self._checkFloat(p)
self._a.extend(p)
def toInt(self):
def toInt(self, *, round=otRound):
if not self.isFloat():
return
a = array.array("h")
for n in self._a:
a.append(otRound(n))
a.append(round(n))
self._a = a
def relativeToAbsolute(self):
@ -1626,9 +1626,9 @@ class GlyphCoordinates(object):
for i in range(len(a)):
a[i] = -a[i]
return r
def __round__(self):
def __round__(self, *, round=otRound):
r = self.copy()
r.toInt()
r.toInt(round=round)
return r
def __add__(self, other): return self.copy().__iadd__(other)