From d24fd7193411ffaa58a78218bbae98e22dc104ba Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 28 Apr 2020 14:28:16 +0200 Subject: [PATCH] [feaLib] Fix building chained alt substitutions Support was added in db49f20d6b2629e1ba25c4afd3fb60817387f3d6, but there was only a parser test and no builder test, fix the build and add a builder test based on the existing parser one. Fixes https://github.com/fonttools/fonttools/issues/1901 --- Lib/fontTools/feaLib/builder.py | 2 +- Tests/feaLib/builder_test.py | 2 +- Tests/feaLib/data/AlternateChained.fea | 3 + Tests/feaLib/data/AlternateChained.ttx | 78 ++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 Tests/feaLib/data/AlternateChained.fea create mode 100644 Tests/feaLib/data/AlternateChained.ttx diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index 72156b8bb..52b23f1b2 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -828,7 +828,7 @@ class Builder(object): if prefix or suffix: chain = self.get_lookup_(location, ChainContextSubstBuilder) lookup = self.get_chained_lookup_(location, AlternateSubstBuilder) - chain.substitutions.append((prefix, [glyph], suffix, [lookup])) + chain.substitutions.append((prefix, [{glyph}], suffix, [lookup])) else: lookup = self.get_lookup_(location, AlternateSubstBuilder) if glyph in lookup.alternates: diff --git a/Tests/feaLib/builder_test.py b/Tests/feaLib/builder_test.py index 3273ba618..5ce4cc266 100644 --- a/Tests/feaLib/builder_test.py +++ b/Tests/feaLib/builder_test.py @@ -71,7 +71,7 @@ class BuilderTest(unittest.TestCase): ZeroValue_ChainSinglePos_horizontal ZeroValue_ChainSinglePos_vertical PairPosSubtable ChainSubstSubtable ChainPosSubtable LigatureSubtable AlternateSubtable MultipleSubstSubtable SingleSubstSubtable - aalt_chain_contextual_subst + aalt_chain_contextual_subst AlternateChained """.split() def __init__(self, methodName): diff --git a/Tests/feaLib/data/AlternateChained.fea b/Tests/feaLib/data/AlternateChained.fea new file mode 100644 index 000000000..45177693e --- /dev/null +++ b/Tests/feaLib/data/AlternateChained.fea @@ -0,0 +1,3 @@ +feature test { + sub A B a' [Y y] Z from [a.alt1 a.alt2 a.alt3]; +} test; diff --git a/Tests/feaLib/data/AlternateChained.ttx b/Tests/feaLib/data/AlternateChained.ttx new file mode 100644 index 000000000..e02bb7d43 --- /dev/null +++ b/Tests/feaLib/data/AlternateChained.ttx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +