models: convert delta array to float if overflows signed short integers

We should check other places where such overflows may occur and do the same.
Or do maybe it in GlyphCoordinates class.
This commit is contained in:
Cosimo Lupo 2018-04-03 11:40:44 +01:00
parent 6b6c34ab1a
commit 0055f9414c
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482

View File

@ -299,7 +299,12 @@ class VariationModel(object):
for i,weights in enumerate(self.deltaWeights): for i,weights in enumerate(self.deltaWeights):
delta = masterValues[mapping[i]] delta = masterValues[mapping[i]]
for j,weight in weights.items(): for j,weight in weights.items():
delta -= out[j] * weight try:
delta -= out[j] * weight
except OverflowError:
# if it doesn't fit signed shorts, retry with doubles
delta._ensureFloat()
delta -= out[j] * weight
out.append(delta) out.append(delta)
return out return out