Merge pull request #3105 from fonttools/deduplicate-multiple-subst-classes
feaLib: Dedupe multiple substitutions with classes
This commit is contained in:
commit
86291b6ef6
@ -1272,15 +1272,18 @@ class MultipleSubstStatement(Statement):
|
|||||||
replaces.append(replace)
|
replaces.append(replace)
|
||||||
replaces = list(zip(*replaces))
|
replaces = list(zip(*replaces))
|
||||||
|
|
||||||
|
seen_originals = set()
|
||||||
for i, original in enumerate(originals):
|
for i, original in enumerate(originals):
|
||||||
builder.add_multiple_subst(
|
if original not in seen_originals:
|
||||||
self.location,
|
seen_originals.add(original)
|
||||||
prefix,
|
builder.add_multiple_subst(
|
||||||
original,
|
self.location,
|
||||||
suffix,
|
prefix,
|
||||||
replaces and replaces[i] or (),
|
original,
|
||||||
self.forceChain,
|
suffix,
|
||||||
)
|
replaces and replaces[i] or (),
|
||||||
|
self.forceChain,
|
||||||
|
)
|
||||||
|
|
||||||
def asFea(self, indent=""):
|
def asFea(self, indent=""):
|
||||||
res = "sub "
|
res = "sub "
|
||||||
|
@ -29,3 +29,7 @@ lookup l1 {
|
|||||||
feature f5 {
|
feature f5 {
|
||||||
sub @class' lookup l1 [i l];
|
sub @class' lookup l1 [i l];
|
||||||
} f5;
|
} f5;
|
||||||
|
|
||||||
|
feature f6 {
|
||||||
|
sub [f_i f_i]' j by [f f] [i i];
|
||||||
|
} f6;
|
||||||
|
@ -10,19 +10,20 @@
|
|||||||
<Script>
|
<Script>
|
||||||
<DefaultLangSys>
|
<DefaultLangSys>
|
||||||
<ReqFeatureIndex value="65535"/>
|
<ReqFeatureIndex value="65535"/>
|
||||||
<!-- FeatureCount=5 -->
|
<!-- FeatureCount=6 -->
|
||||||
<FeatureIndex index="0" value="0"/>
|
<FeatureIndex index="0" value="0"/>
|
||||||
<FeatureIndex index="1" value="1"/>
|
<FeatureIndex index="1" value="1"/>
|
||||||
<FeatureIndex index="2" value="2"/>
|
<FeatureIndex index="2" value="2"/>
|
||||||
<FeatureIndex index="3" value="3"/>
|
<FeatureIndex index="3" value="3"/>
|
||||||
<FeatureIndex index="4" value="4"/>
|
<FeatureIndex index="4" value="4"/>
|
||||||
|
<FeatureIndex index="5" value="5"/>
|
||||||
</DefaultLangSys>
|
</DefaultLangSys>
|
||||||
<!-- LangSysCount=0 -->
|
<!-- LangSysCount=0 -->
|
||||||
</Script>
|
</Script>
|
||||||
</ScriptRecord>
|
</ScriptRecord>
|
||||||
</ScriptList>
|
</ScriptList>
|
||||||
<FeatureList>
|
<FeatureList>
|
||||||
<!-- FeatureCount=5 -->
|
<!-- FeatureCount=6 -->
|
||||||
<FeatureRecord index="0">
|
<FeatureRecord index="0">
|
||||||
<FeatureTag value="f1 "/>
|
<FeatureTag value="f1 "/>
|
||||||
<Feature>
|
<Feature>
|
||||||
@ -58,9 +59,16 @@
|
|||||||
<LookupListIndex index="0" value="5"/>
|
<LookupListIndex index="0" value="5"/>
|
||||||
</Feature>
|
</Feature>
|
||||||
</FeatureRecord>
|
</FeatureRecord>
|
||||||
|
<FeatureRecord index="5">
|
||||||
|
<FeatureTag value="f6 "/>
|
||||||
|
<Feature>
|
||||||
|
<!-- LookupCount=1 -->
|
||||||
|
<LookupListIndex index="0" value="6"/>
|
||||||
|
</Feature>
|
||||||
|
</FeatureRecord>
|
||||||
</FeatureList>
|
</FeatureList>
|
||||||
<LookupList>
|
<LookupList>
|
||||||
<!-- LookupCount=6 -->
|
<!-- LookupCount=8 -->
|
||||||
<Lookup index="0">
|
<Lookup index="0">
|
||||||
<LookupType value="2"/>
|
<LookupType value="2"/>
|
||||||
<LookupFlag value="0"/>
|
<LookupFlag value="0"/>
|
||||||
@ -135,6 +143,35 @@
|
|||||||
</SubstLookupRecord>
|
</SubstLookupRecord>
|
||||||
</ChainContextSubst>
|
</ChainContextSubst>
|
||||||
</Lookup>
|
</Lookup>
|
||||||
|
<Lookup index="6">
|
||||||
|
<LookupType value="6"/>
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<ChainContextSubst index="0" Format="3">
|
||||||
|
<!-- BacktrackGlyphCount=0 -->
|
||||||
|
<!-- InputGlyphCount=1 -->
|
||||||
|
<InputCoverage index="0">
|
||||||
|
<Glyph value="f_i"/>
|
||||||
|
</InputCoverage>
|
||||||
|
<!-- LookAheadGlyphCount=1 -->
|
||||||
|
<LookAheadCoverage index="0">
|
||||||
|
<Glyph value="j"/>
|
||||||
|
</LookAheadCoverage>
|
||||||
|
<!-- SubstCount=1 -->
|
||||||
|
<SubstLookupRecord index="0">
|
||||||
|
<SequenceIndex value="0"/>
|
||||||
|
<LookupListIndex value="7"/>
|
||||||
|
</SubstLookupRecord>
|
||||||
|
</ChainContextSubst>
|
||||||
|
</Lookup>
|
||||||
|
<Lookup index="7">
|
||||||
|
<LookupType value="2"/>
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<MultipleSubst index="0">
|
||||||
|
<Substitution in="f_i" out="f,i"/>
|
||||||
|
</MultipleSubst>
|
||||||
|
</Lookup>
|
||||||
</LookupList>
|
</LookupList>
|
||||||
</GSUB>
|
</GSUB>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user