[feaLib] Don’t hard-code "subtable" support

Allow for making more lookups support subtabe breaks. Although AFDKO’s
makeotf supports subtable breaks only in pair pos lookups, I believe
that is an implementation limit that we don’t have to follow; all
OpenType lookups has subtables and it should be possible to code that in
the feature files.
This commit is contained in:
Khaled Hosny 2019-02-25 23:30:03 +02:00
parent 0cc1dda00d
commit 6bb0545655
2 changed files with 8 additions and 9 deletions

View File

@ -996,14 +996,7 @@ class Builder(object):
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)
self.cur_lookup_.add_subtable_break(location)
def add_specific_pair_pos(self, location, glyph1, value1, glyph2, value2):
lookup = self.get_lookup_(location, PairPosBuilder)
@ -1191,6 +1184,12 @@ class LookupBuilder(object):
coverage = otl.buildCoverage(g, self.glyphMap)
subtable.InputCoverage.append(coverage)
def add_subtable_break(self, location):
raise FeatureLibError(
'unsupported "subtable" statement for lookup type',
location
)
class AlternateSubstBuilder(LookupBuilder):
def __init__(self, font, location):

View File

@ -515,7 +515,7 @@ class BuilderTest(unittest.TestCase):
def test_unsupported_subtable_break(self):
self.assertRaisesRegex(
FeatureLibError,
'explicit "subtable" statement is intended for .* class kerning',
'unsupported "subtable" statement for lookup type',
self.build,
"feature liga {"
" sub f f by f_f;"