From 8ed77926826fc68d07194929da1a9a2821ae535c Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 23 Sep 2020 10:10:38 +0100 Subject: [PATCH 1/2] Only stash lookup location if buildLookups_ has cooperated Fixes #2065 --- Lib/fontTools/feaLib/builder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index f8b6a33b0..f71a77310 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -707,9 +707,10 @@ class Builder(object): continue for ix in lookup_indices: - self.lookup_locations[tag][str(ix)] = self.lookup_locations[tag][ - str(ix) - ]._replace(feature=key) + if str(ix) in self.lookup_locations[tag]: + self.lookup_locations[tag][str(ix)] = self.lookup_locations[tag][ + str(ix) + ]._replace(feature=key) feature_key = (feature_tag, lookup_indices) feature_index = feature_indices.get(feature_key) From 0c9cb3a87806f5d51f1508d353bc6c389ec2eee2 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Sun, 18 Oct 2020 11:21:49 +0100 Subject: [PATCH 2/2] Warn developer if subclass needs upgrading --- Lib/fontTools/feaLib/builder.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index f71a77310..6baaeeb24 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -30,6 +30,7 @@ from fontTools.otlLib.error import OpenTypeLibError from collections import defaultdict import itertools import logging +import warnings log = logging.getLogger(__name__) @@ -707,10 +708,13 @@ class Builder(object): continue for ix in lookup_indices: - if str(ix) in self.lookup_locations[tag]: + try: self.lookup_locations[tag][str(ix)] = self.lookup_locations[tag][ str(ix) ]._replace(feature=key) + except KeyError: + warnings.warn("feaLib.Builder subclass needs upgrading to " + "stash debug information. See fonttools#2065.") feature_key = (feature_tag, lookup_indices) feature_index = feature_indices.get(feature_key)