varLib.models: fix KeyError when no on-axis points while sorting masters

E.g. when trying to model/plot an unusual designspace like: fonttools varLib.plot 0,0 -1,-1 1,-1 -1,1 1,1
This commit is contained in:
Cosimo Lupo 2019-08-12 12:59:28 +02:00
parent 630a31e552
commit 38a8eb0e34
No known key found for this signature in database
GPG Key ID: 179A8F0895A02F4F

View File

@ -239,7 +239,11 @@ class VariationModel(object):
return -1 if v < 0 else +1 if v > 0 else 0
def key(loc):
rank = len(loc)
onPointAxes = [axis for axis,value in loc.items() if value in axisPoints[axis]]
onPointAxes = [
axis for axis, value in loc.items()
if axis in axisPoints
and value in axisPoints[axis]
]
orderedAxes = [axis for axis in axisOrder if axis in loc]
orderedAxes.extend([axis for axis in sorted(loc.keys()) if axis not in axisOrder])
return (