From 8d1930a27a302256f8566e9a11fd4d1a442d3f1c Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sun, 13 Mar 2016 00:16:27 +0400 Subject: [PATCH] Fix handling of default lookupflag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the spec: > The lookupflag attribute defaults to 0 at the start of a feature > block. > > The lookupflag attribute stays the same until explicitly changed, until > a lookup reference statement is encountered that changes it, until the > script is changed, or until the end of the feature. This is an attempt to fix this by resetting the lookupflag at the start and end of feature/lookup blacks. I’m not sure if resetting it in lookup blocks is correct (my reading of the spec suggests it is not), but one needs to test this against makeotf and see how it behaves here. --- Lib/fontTools/feaLib/builder.py | 8 ++++++++ Lib/fontTools/feaLib/testdata/lookupflag.fea | 4 ++++ Lib/fontTools/feaLib/testdata/lookupflag.ttx | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index 1567cc79a..b9782052d 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -338,6 +338,8 @@ class Builder(object): self.language_systems = self.get_default_language_systems_() self.cur_lookup_ = None self.cur_feature_name_ = name + self.lookupflag_ = 0 + self.lookupflag_markFilterSet_ = None if name == "aalt": self.aalt_location_ = location @@ -346,6 +348,8 @@ class Builder(object): self.cur_feature_name_ = None self.language_systems = None self.cur_lookup_ = None + self.lookupflag_ = 0 + self.lookupflag_markFilterSet_ = None def start_lookup_block(self, location, name): if name in self.named_lookups_: @@ -359,11 +363,15 @@ class Builder(object): self.cur_lookup_name_ = name self.named_lookups_[name] = None self.cur_lookup_ = None + self.lookupflag_ = 0 + self.lookupflag_markFilterSet_ = None def end_lookup_block(self): assert self.cur_lookup_name_ is not None self.cur_lookup_name_ = None self.cur_lookup_ = None + self.lookupflag_ = 0 + self.lookupflag_markFilterSet_ = None def add_lookup_call(self, lookup_name): assert lookup_name in self.named_lookups_, lookup_name diff --git a/Lib/fontTools/feaLib/testdata/lookupflag.fea b/Lib/fontTools/feaLib/testdata/lookupflag.fea index 9b6f346d7..359da711f 100644 --- a/Lib/fontTools/feaLib/testdata/lookupflag.fea +++ b/Lib/fontTools/feaLib/testdata/lookupflag.fea @@ -63,6 +63,9 @@ lookup K { pos K 1; } K; +lookup L { + pos L 1; +} L; feature test { lookup A; @@ -76,4 +79,5 @@ feature test { lookup I; lookup J; lookup K; + lookup L; } test; diff --git a/Lib/fontTools/feaLib/testdata/lookupflag.ttx b/Lib/fontTools/feaLib/testdata/lookupflag.ttx index d4c6c435b..708733228 100644 --- a/Lib/fontTools/feaLib/testdata/lookupflag.ttx +++ b/Lib/fontTools/feaLib/testdata/lookupflag.ttx @@ -53,7 +53,7 @@ - + @@ -65,11 +65,12 @@ + - + @@ -205,6 +206,18 @@ + + + + + + + + + + + +