diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index 6e654374a..51d57c792 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -1311,9 +1311,10 @@ class ChainContextSubstBuilder(LookupBuilder): if lookups == self.SUBTABLE_BREAK_: continue for lookup in lookups: - alts = lookup.getAlternateGlyphs() - for glyph, replacements in alts.items(): - result.setdefault(glyph, set()).update(replacements) + if lookup is not None: + alts = lookup.getAlternateGlyphs() + for glyph, replacements in alts.items(): + result.setdefault(glyph, set()).update(replacements) return result def find_chainable_single_subst(self, glyphs): diff --git a/Tests/feaLib/builder_test.py b/Tests/feaLib/builder_test.py index 8120d25c1..a00525cfd 100644 --- a/Tests/feaLib/builder_test.py +++ b/Tests/feaLib/builder_test.py @@ -71,6 +71,7 @@ class BuilderTest(unittest.TestCase): ZeroValue_ChainSinglePos_horizontal ZeroValue_ChainSinglePos_vertical PairPosSubtable ChainSubstSubtable ChainPosSubtable LigatureSubtable AlternateSubtable MultipleSubstSubtable SingleSubstSubtable + aalt_chain_contextual_subst """.split() def __init__(self, methodName): diff --git a/Tests/feaLib/data/aalt_chain_contextual_subst.fea b/Tests/feaLib/data/aalt_chain_contextual_subst.fea new file mode 100644 index 000000000..677c23042 --- /dev/null +++ b/Tests/feaLib/data/aalt_chain_contextual_subst.fea @@ -0,0 +1,20 @@ +# https://github.com/googlefonts/fontmake/issues/648 + +lookup CNTXT_LIGS { + sub f i by f_i; + sub c t by c_t; +} CNTXT_LIGS; + +lookup CNTXT_SUB { + sub n by n.end; + sub s by s.end; +} CNTXT_SUB; + +feature calt { + sub [a e i o u] f' lookup CNTXT_LIGS i' n' lookup CNTXT_SUB; + sub [a e i o u] c' lookup CNTXT_LIGS t' s' lookup CNTXT_SUB; +} calt; + +feature aalt { + feature calt; +} aalt; diff --git a/Tests/feaLib/data/aalt_chain_contextual_subst.ttx b/Tests/feaLib/data/aalt_chain_contextual_subst.ttx new file mode 100644 index 000000000..256a9c72e --- /dev/null +++ b/Tests/feaLib/data/aalt_chain_contextual_subst.ttx @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +