[feaLib] Reverse lookup order for chained single substitutions

This makes feaLib's output more similar to output from makeotf.
Resolves https://github.com/behdad/fonttools/issues/507.
This commit is contained in:
Sascha Brawer 2016-02-04 15:07:47 +01:00
parent 3d6cf0d8e6
commit ea4a4e34b3
7 changed files with 94 additions and 94 deletions

View File

@ -555,10 +555,10 @@ class Builder(object):
alts.add(to_glyph)
return
if prefix or suffix:
chain = self.get_lookup_(location, ChainContextSubstBuilder)
sub = self.get_chained_lookup_(location, SingleSubstBuilder)
sub.mapping.update(mapping)
lookup = self.get_lookup_(location, ChainContextSubstBuilder)
lookup.substitutions.append(
chain.substitutions.append(
(prefix, [mapping.keys()], suffix, [sub]))
return
lookup = self.get_lookup_(location, SingleSubstBuilder)

View File

@ -23,7 +23,7 @@
<FeatureTag value="test"/>
<Feature>
<!-- LookupCount=5 -->
<LookupListIndex index="0" value="1"/>
<LookupListIndex index="0" value="0"/>
<LookupListIndex index="1" value="3"/>
<LookupListIndex index="2" value="5"/>
<LookupListIndex index="3" value="7"/>
@ -34,14 +34,6 @@
<LookupList>
<!-- LookupCount=10 -->
<Lookup index="0">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A" out="A.sc"/>
</SingleSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=6 -->
<LookupFlag value="0"/>
<!-- SubTableCount=2 -->
@ -62,7 +54,7 @@
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="0"/>
<LookupListIndex value="1"/>
</SubstLookupRecord>
</ChainContextSubst>
<ChainContextSubst index="1" Format="3">
@ -88,6 +80,14 @@
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A" out="A.sc"/>
</SingleSubst>
</Lookup>
<Lookup index="2">
<!-- LookupType=1 -->
<LookupFlag value="0"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont>
<ttFont sfntVersion="true" ttLibVersion="3.0">
<GSUB>
<Version value="1.0"/>
@ -23,22 +23,13 @@
<FeatureTag value="ordn"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="1"/>
<LookupListIndex index="0" value="0"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=3 -->
<Lookup index="0">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A" out="ordfeminine"/>
<Substitution in="a" out="ordfeminine"/>
</SingleSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=6 -->
<LookupFlag value="0"/>
<!-- SubTableCount=2 -->
@ -65,7 +56,7 @@
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="0"/>
<LookupListIndex value="1"/>
</SubstLookupRecord>
</ChainContextSubst>
<ChainContextSubst index="1" Format="3">
@ -95,6 +86,15 @@
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A" out="ordfeminine"/>
<Substitution in="a" out="ordfeminine"/>
</SingleSubst>
</Lookup>
<Lookup index="2">
<!-- LookupType=1 -->
<LookupFlag value="0"/>

View File

@ -48,7 +48,7 @@
<FeatureTag value="ordn"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="4"/>
<LookupListIndex index="0" value="3"/>
</Feature>
</FeatureRecord>
<FeatureRecord index="4">
@ -100,15 +100,6 @@
</LigatureSubst>
</Lookup>
<Lookup index="3">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A" out="ordfeminine"/>
<Substitution in="a" out="ordfeminine"/>
</SingleSubst>
</Lookup>
<Lookup index="4">
<!-- LookupType=6 -->
<LookupFlag value="0"/>
<!-- SubTableCount=2 -->
@ -135,7 +126,7 @@
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="3"/>
<LookupListIndex value="4"/>
</SubstLookupRecord>
</ChainContextSubst>
<ChainContextSubst index="1" Format="3">
@ -165,6 +156,15 @@
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="4">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A" out="ordfeminine"/>
<Substitution in="a" out="ordfeminine"/>
</SingleSubst>
</Lookup>
<Lookup index="5">
<!-- LookupType=1 -->
<LookupFlag value="0"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont>
<ttFont sfntVersion="true" ttLibVersion="3.0">
<GSUB>
<Version value="1.0"/>
@ -23,21 +23,13 @@
<FeatureTag value="test"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="1"/>
<LookupListIndex index="0" value="0"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=2 -->
<Lookup index="0">
<!-- LookupType=1 -->
<LookupFlag value="7"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="d" out="d.alt"/>
</SingleSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=6 -->
<LookupFlag value="7"/>
<!-- SubTableCount=1 -->
@ -56,10 +48,18 @@
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="0"/>
<LookupListIndex value="1"/>
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=1 -->
<LookupFlag value="7"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="d" out="d.alt"/>
</SingleSubst>
</Lookup>
</LookupList>
</GSUB>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont>
<ttFont sfntVersion="true" ttLibVersion="3.0">
<GSUB>
<Version value="1.0"/>
@ -23,46 +23,13 @@
<FeatureTag value="test"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="1"/>
<LookupListIndex index="0" value="0"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=2 -->
<Lookup index="0">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A.sc" out="a"/>
<Substitution in="B.sc" out="b"/>
<Substitution in="C.sc" out="c"/>
<Substitution in="D.sc" out="d"/>
<Substitution in="E.sc" out="e"/>
<Substitution in="F.sc" out="f"/>
<Substitution in="G.sc" out="g"/>
<Substitution in="H.sc" out="h"/>
<Substitution in="I.sc" out="i"/>
<Substitution in="J.sc" out="j"/>
<Substitution in="K.sc" out="k"/>
<Substitution in="L.sc" out="l"/>
<Substitution in="M.sc" out="m"/>
<Substitution in="N.sc" out="n"/>
<Substitution in="O.sc" out="o"/>
<Substitution in="P.sc" out="p"/>
<Substitution in="Q.sc" out="q"/>
<Substitution in="R.sc" out="r"/>
<Substitution in="S.sc" out="s"/>
<Substitution in="T.sc" out="t"/>
<Substitution in="U.sc" out="u"/>
<Substitution in="V.sc" out="v"/>
<Substitution in="W.sc" out="w"/>
<Substitution in="X.sc" out="x"/>
<Substitution in="Y.sc" out="y"/>
<Substitution in="Z.sc" out="z"/>
</SingleSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=6 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
@ -129,10 +96,43 @@
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="0"/>
<LookupListIndex value="1"/>
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="1">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="A.sc" out="a"/>
<Substitution in="B.sc" out="b"/>
<Substitution in="C.sc" out="c"/>
<Substitution in="D.sc" out="d"/>
<Substitution in="E.sc" out="e"/>
<Substitution in="F.sc" out="f"/>
<Substitution in="G.sc" out="g"/>
<Substitution in="H.sc" out="h"/>
<Substitution in="I.sc" out="i"/>
<Substitution in="J.sc" out="j"/>
<Substitution in="K.sc" out="k"/>
<Substitution in="L.sc" out="l"/>
<Substitution in="M.sc" out="m"/>
<Substitution in="N.sc" out="n"/>
<Substitution in="O.sc" out="o"/>
<Substitution in="P.sc" out="p"/>
<Substitution in="Q.sc" out="q"/>
<Substitution in="R.sc" out="r"/>
<Substitution in="S.sc" out="s"/>
<Substitution in="T.sc" out="t"/>
<Substitution in="U.sc" out="u"/>
<Substitution in="V.sc" out="v"/>
<Substitution in="W.sc" out="w"/>
<Substitution in="X.sc" out="x"/>
<Substitution in="Y.sc" out="y"/>
<Substitution in="Z.sc" out="z"/>
</SingleSubst>
</Lookup>
</LookupList>
</GSUB>

View File

@ -70,7 +70,7 @@
<Feature>
<!-- LookupCount=3 -->
<LookupListIndex index="0" value="4"/>
<LookupListIndex index="1" value="6"/>
<LookupListIndex index="1" value="5"/>
<LookupListIndex index="2" value="7"/>
</Feature>
</FeatureRecord>
@ -151,16 +151,6 @@
</AlternateSubst>
</Lookup>
<Lookup index="5">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="c" out="c.mid"/>
<Substitution in="d" out="d.mid"/>
<Substitution in="e" out="e.mid"/>
</SingleSubst>
</Lookup>
<Lookup index="6">
<!-- LookupType=6 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
@ -182,10 +172,20 @@
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="5"/>
<LookupListIndex value="6"/>
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="6">
<!-- LookupType=1 -->
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SingleSubst index="0">
<Substitution in="c" out="c.mid"/>
<Substitution in="d" out="d.mid"/>
<Substitution in="e" out="e.mid"/>
</SingleSubst>
</Lookup>
<Lookup index="7">
<!-- LookupType=1 -->
<LookupFlag value="0"/>