[gvar] Remove GlyphCoordinates.__abs__()

It's not wel-defined, as abs typically is supposed to return a scalar...

Also combine the tolerance-check with the zero-check in varLib.
This commit is contained in:
Behdad Esfahbod 2017-05-18 16:02:58 -07:00
parent e46f94950c
commit 3db5be2195
2 changed files with 3 additions and 19 deletions

View File

@ -1355,22 +1355,6 @@ class GlyphCoordinates(object):
for i in range(len(a)):
a[i] = -a[i]
return r
def __abs__(self):
"""
>>> g = GlyphCoordinates([(-1.5,2)])
>>> g
GlyphCoordinates([(-1.5, 2.0)])
>>> g2 = abs(g)
>>> g
GlyphCoordinates([(-1.5, 2.0)])
>>> g2
GlyphCoordinates([(1.5, 2.0)])
"""
r = self.copy()
a = r._a
for i in range(len(a)):
a[i] = abs(a[i])
return r
def __round__(self):
"""
Note: This is Python 3 only. Python 2 does not call __round__.

View File

@ -232,6 +232,8 @@ def _optimize_delta(delta, coords, ends):
def _add_gvar(font, model, master_ttfs, tolerance=.5, optimize=True):
assert tolerance >= 0
log.info("Generating gvar")
assert "gvar" not in font
gvar = font["gvar"] = newTable('gvar')
@ -261,9 +263,7 @@ def _add_gvar(font, model, master_ttfs, tolerance=.5, optimize=True):
endPts = control[1] if control[0] >= 1 else list(range(len(control[1])))
for i,(delta,support) in enumerate(zip(deltas[1:], supports[1:])):
if all(0 == v for v in delta.array):
continue
if tolerance and max(abs(delta).array) <= tolerance: # XXX
if all(abs(v) <= tolerance for v in delta.array):
continue
var = TupleVariation(support, delta)
if optimize: