From 890c5061b5058c5de08b12a5bf54c161bac3d25e Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 11 May 2020 13:32:18 +0100 Subject: [PATCH] subset: fix issue subsetting Context{Subst,Pos}Format3 Fixes https://github.com/fonttools/fonttools/issues/1879 In ChainContext{Subst,Pos}Format3, the array of input coverages is called InputCoverage, whereas in non-Chain Context{Subst,Pos}Format3 subtables it is called simply Coverage. --- Lib/fontTools/subset/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/subset/__init__.py b/Lib/fontTools/subset/__init__.py index 0119a92bd..701c1aa25 100644 --- a/Lib/fontTools/subset/__init__.py +++ b/Lib/fontTools/subset/__init__.py @@ -894,6 +894,8 @@ def __subset_classify_context(self): self.ClassDef = 'InputClassDef' if Chain else 'ClassDef' self.ClassDefIndex = 1 if Chain else 0 self.Input = 'Input' if Chain else 'Class' + elif Format == 3: + self.Input = 'InputCoverage' if Chain else 'Coverage' if self.Format not in [1, 2, 3]: return None # Don't shoot the messenger; let it go @@ -976,6 +978,7 @@ def closure_glyphs(self, s, cur_glyphs): if not all(x.intersect(s.glyphs) for x in c.RuleData(self)): return [] r = self + input_coverages = getattr(r, c.Input) chaos = set() for ll in getattr(r, c.LookupRecord): if not ll: continue @@ -987,11 +990,11 @@ def closure_glyphs(self, s, cur_glyphs): if seqi == 0: pos_glyphs = frozenset(cur_glyphs) else: - pos_glyphs = frozenset(r.InputCoverage[seqi].intersect_glyphs(s.glyphs)) + pos_glyphs = frozenset(input_coverages[seqi].intersect_glyphs(s.glyphs)) lookup = s.table.LookupList.Lookup[ll.LookupListIndex] chaos.add(seqi) if lookup.may_have_non_1to1(): - chaos.update(range(seqi, len(r.InputCoverage)+1)) + chaos.update(range(seqi, len(input_coverages)+1)) lookup.closure_glyphs(s, cur_glyphs=pos_glyphs) else: assert 0, "unknown format: %s" % self.Format