From 67686691c48b7ea68a32eb45ee4f41b56e9be12a Mon Sep 17 00:00:00 2001 From: Sascha Brawer Date: Mon, 11 Jan 2016 18:12:23 +0100 Subject: [PATCH] [feaLib] Also handle `feature aalt` without any custom lookups Before this change, feaLib did not handle feature files that specified `feature aalt` whose block just was referring to other features without defining any lookups on its own. After this change, we can handle it. Resolves https://github.com/behdad/fonttools/issues/441 --- Lib/fontTools/feaLib/builder.py | 3 +- Lib/fontTools/feaLib/builder_test.py | 2 +- .../feaLib/testdata/feature_aalt.fea | 31 +++ .../feaLib/testdata/feature_aalt.ttx | 191 ++++++++++++++++++ 4 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 Lib/fontTools/feaLib/testdata/feature_aalt.fea create mode 100644 Lib/fontTools/feaLib/testdata/feature_aalt.ttx diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index 20c0b9969..10e1446c0 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -110,7 +110,8 @@ class Builder(object): for (script, lang, feature), lookups in self.features_.items() if feature == name] - if not feature: + # "aalt" does not have to specify its own lookups, but it might. + if not feature and name != "aalt": raise FeatureLibError("Feature %s has not been defined" % name, location) for script, lang, feature, lookups in feature: diff --git a/Lib/fontTools/feaLib/builder_test.py b/Lib/fontTools/feaLib/builder_test.py index db16ad76e..bf1619506 100644 --- a/Lib/fontTools/feaLib/builder_test.py +++ b/Lib/fontTools/feaLib/builder_test.py @@ -149,7 +149,7 @@ class BuilderTest(unittest.TestCase): def test_constructs(self): for name in ("Attach enum markClass language_required " "GlyphClassDef LigatureCaretByIndex LigatureCaretByPos " - "lookup lookupflag").split(): + "lookup lookupflag feature_aalt").split(): font = makeTTFont() addOpenTypeFeatures(self.getpath("%s.fea" % name), font) self.expect_ttx(font, self.getpath("%s.ttx" % name)) diff --git a/Lib/fontTools/feaLib/testdata/feature_aalt.fea b/Lib/fontTools/feaLib/testdata/feature_aalt.fea new file mode 100644 index 000000000..3e29cfc5d --- /dev/null +++ b/Lib/fontTools/feaLib/testdata/feature_aalt.fea @@ -0,0 +1,31 @@ +languagesystem DFLT dflt; + +feature aalt { + feature sups; + feature frac; + feature ordn; +} aalt; + +feature sups { + sub one by onesuperior; + sub two by twosuperior; + sub three by threesuperior; +} sups; + +feature frac { + sub one slash four by onequarter; + sub one slash two by onehalf; + sub three slash four by threequarters; +} frac; + +feature ordn { + sub [zero one two three four five six seven eight nine] [A a]' + by ordfeminine; + sub [zero one two three four five six seven eight nine] [O o]' + by ordmasculine; +} ordn; + +feature liga { + sub f i by fi; + sub f l by fl; +} liga; diff --git a/Lib/fontTools/feaLib/testdata/feature_aalt.ttx b/Lib/fontTools/feaLib/testdata/feature_aalt.ttx new file mode 100644 index 000000000..9fff95e8a --- /dev/null +++ b/Lib/fontTools/feaLib/testdata/feature_aalt.ttx @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +