From 9456ae9485cb37885a80fda280c8a0262f0a76de Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 24 Jul 2018 17:13:52 +0100 Subject: [PATCH] feaLib: support explicit 'subtable' statements in PairPos lookups Fixes https://github.com/fonttools/fonttools/issues/1279 --- Lib/fontTools/feaLib/ast.py | 3 +++ Lib/fontTools/feaLib/builder.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/Lib/fontTools/feaLib/ast.py b/Lib/fontTools/feaLib/ast.py index 3c2c5f667..7f33ca41c 100644 --- a/Lib/fontTools/feaLib/ast.py +++ b/Lib/fontTools/feaLib/ast.py @@ -1077,6 +1077,9 @@ class SubtableStatement(Statement): def __init__(self, location=None): Statement.__init__(self, location) + def build(self, builder): + builder.add_subtable_break(self.location) + def asFea(self, indent=""): return indent + "subtable;" diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index ea2aa4930..0b14afbba 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -999,6 +999,16 @@ class Builder(object): lookup = self.get_lookup_(location, PairPosBuilder) lookup.addClassPair(location, glyphclass1, value1, glyphclass2, value2) + def add_subtable_break(self, location): + if type(self.cur_lookup_) is not PairPosBuilder: + raise FeatureLibError( + 'explicit "subtable" statement is intended for use with only ' + "Pair Adjustment Positioning Format 2 (i.e. pair class kerning)", + location + ) + lookup = self.get_lookup_(location, PairPosBuilder) + lookup.add_subtable_break(location) + def add_specific_pair_pos(self, location, glyph1, value1, glyph2, value2): lookup = self.get_lookup_(location, PairPosBuilder) lookup.addGlyphPair(location, glyph1, value1, glyph2, value2)