[feaLib] "subtable" in multiple substitutions

This commit is contained in:
Khaled Hosny 2019-02-26 18:42:14 +02:00
parent c87e5cf4ad
commit d9893ab05a
4 changed files with 65 additions and 3 deletions

View File

@ -1345,8 +1345,19 @@ class MultipleSubstBuilder(LookupBuilder):
self.mapping == other.mapping)
def build(self):
subtable = otl.buildMultipleSubstSubtable(self.mapping)
return self.buildLookup_([subtable])
subtables = []
mapping = {}
for key in self.mapping:
if key[0] == self.SUBTABLE_BREAK_:
subtables.append(otl.buildMultipleSubstSubtable(mapping))
mapping = {}
else:
mapping[key] = self.mapping[key]
subtables.append(otl.buildMultipleSubstSubtable(mapping))
return self.buildLookup_(subtables)
def add_subtable_break(self, location):
self.mapping[(self.SUBTABLE_BREAK_, location)] = self.SUBTABLE_BREAK_
class CursivePosBuilder(LookupBuilder):

View File

@ -71,7 +71,7 @@ class BuilderTest(unittest.TestCase):
ZeroValue_PairPos_horizontal ZeroValue_PairPos_vertical
ZeroValue_ChainSinglePos_horizontal ZeroValue_ChainSinglePos_vertical
PairPosSubtable ChainSubstSubtable ChainPosSubtable LigatureSubtable
AlternateSubtable
AlternateSubtable MultipleSubstSubtable
""".split()
def __init__(self, methodName):

View File

@ -0,0 +1,5 @@
feature test {
sub c_t by c t;
subtable;
sub f_i by f i;
} test;

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont>
<GSUB>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
</ScriptList>
<FeatureList>
<!-- FeatureCount=1 -->
<FeatureRecord index="0">
<FeatureTag value="test"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="0"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=1 -->
<Lookup index="0">
<LookupType value="2"/>
<LookupFlag value="0"/>
<!-- SubTableCount=2 -->
<MultipleSubst index="0">
<Substitution in="c_t" out="c,t"/>
</MultipleSubst>
<MultipleSubst index="1">
<Substitution in="f_i" out="f,i"/>
</MultipleSubst>
</Lookup>
</LookupList>
</GSUB>
</ttFont>