From 38a8eb0e34c6c67a47357f36f4accbc69e7a1a20 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 12 Aug 2019 12:59:28 +0200 Subject: [PATCH] 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 --- Lib/fontTools/varLib/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/varLib/models.py b/Lib/fontTools/varLib/models.py index ac2f65f33..2ffe33e2a 100644 --- a/Lib/fontTools/varLib/models.py +++ b/Lib/fontTools/varLib/models.py @@ -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 (