[feaLib] "subtable" in single substitutions
This commit is contained in:
parent
3be73365a5
commit
226f5518b7
@ -1509,12 +1509,23 @@ class SingleSubstBuilder(LookupBuilder):
|
||||
self.mapping == other.mapping)
|
||||
|
||||
def build(self):
|
||||
subtable = otl.buildSingleSubstSubtable(self.mapping)
|
||||
return self.buildLookup_([subtable])
|
||||
subtables = []
|
||||
mapping = {}
|
||||
for key in self.mapping:
|
||||
if key[0] == self.SUBTABLE_BREAK_:
|
||||
subtables.append(otl.buildSingleSubstSubtable(mapping))
|
||||
mapping = {}
|
||||
else:
|
||||
mapping[key] = self.mapping[key]
|
||||
subtables.append(otl.buildSingleSubstSubtable(mapping))
|
||||
return self.buildLookup_(subtables)
|
||||
|
||||
def getAlternateGlyphs(self):
|
||||
return {glyph: set([repl]) for glyph, repl in self.mapping.items()}
|
||||
|
||||
def add_subtable_break(self, location):
|
||||
self.mapping[(self.SUBTABLE_BREAK_, location)] = self.SUBTABLE_BREAK_
|
||||
|
||||
|
||||
class ClassPairPosSubtableBuilder(object):
|
||||
def __init__(self, builder, valueFormat1, valueFormat2):
|
||||
|
@ -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 MultipleSubstSubtable
|
||||
AlternateSubtable MultipleSubstSubtable SingleSubstSubtable
|
||||
""".split()
|
||||
|
||||
def __init__(self, methodName):
|
||||
@ -519,9 +519,9 @@ class BuilderTest(unittest.TestCase):
|
||||
'unsupported "subtable" statement for lookup type',
|
||||
self.build,
|
||||
"feature test {"
|
||||
" sub a by b;"
|
||||
" pos a 10;"
|
||||
" subtable;"
|
||||
" sub c by d;"
|
||||
" pos b 10;"
|
||||
"} test;"
|
||||
)
|
||||
|
||||
|
5
Tests/feaLib/data/SingleSubstSubtable.fea
Normal file
5
Tests/feaLib/data/SingleSubstSubtable.fea
Normal file
@ -0,0 +1,5 @@
|
||||
feature test {
|
||||
sub a by b;
|
||||
subtable;
|
||||
sub c by d;
|
||||
} test;
|
46
Tests/feaLib/data/SingleSubstSubtable.ttx
Normal file
46
Tests/feaLib/data/SingleSubstSubtable.ttx
Normal 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="1"/>
|
||||
<LookupFlag value="0"/>
|
||||
<!-- SubTableCount=2 -->
|
||||
<SingleSubst index="0">
|
||||
<Substitution in="a" out="b"/>
|
||||
</SingleSubst>
|
||||
<SingleSubst index="1">
|
||||
<Substitution in="c" out="d"/>
|
||||
</SingleSubst>
|
||||
</Lookup>
|
||||
</LookupList>
|
||||
</GSUB>
|
||||
|
||||
</ttFont>
|
Loading…
x
Reference in New Issue
Block a user