Merge pull request #356 from anthrotype/feaLib-fix
[feaLib] make LookupList.Lookup into a list of Lookup objects, not subtables
This commit is contained in:
commit
d927ccf2a6
@ -299,9 +299,15 @@ class AlternateSubstBuilder(LookupBuilder):
|
|||||||
self.alternates == other.alternates)
|
self.alternates == other.alternates)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
lookup = otTables.AlternateSubst()
|
lookup = otTables.Lookup()
|
||||||
lookup.Format = 1
|
lookup.SubTable = []
|
||||||
lookup.alternates = self.alternates
|
st = otTables.AlternateSubst()
|
||||||
|
st.Format = 1
|
||||||
|
st.alternates = self.alternates
|
||||||
|
lookup.SubTable.append(st)
|
||||||
|
lookup.LookupFlag = self.lookup_flag
|
||||||
|
lookup.LookupType = self.lookup_type
|
||||||
|
lookup.SubTableCount = len(lookup.SubTable)
|
||||||
return lookup
|
return lookup
|
||||||
|
|
||||||
|
|
||||||
@ -329,14 +335,20 @@ class LigatureSubstBuilder(LookupBuilder):
|
|||||||
return (-len(components), components)
|
return (-len(components), components)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
lookup = otTables.LigatureSubst()
|
lookup = otTables.Lookup()
|
||||||
lookup.Format = 1
|
lookup.SubTable = []
|
||||||
lookup.ligatures = {}
|
st = otTables.LigatureSubst()
|
||||||
|
st.Format = 1
|
||||||
|
st.ligatures = {}
|
||||||
for components in sorted(self.ligatures.keys(), key=self.make_key):
|
for components in sorted(self.ligatures.keys(), key=self.make_key):
|
||||||
lig = otTables.Ligature()
|
lig = otTables.Ligature()
|
||||||
lig.Component = components
|
lig.Component = components
|
||||||
lig.LigGlyph = self.ligatures[components]
|
lig.LigGlyph = self.ligatures[components]
|
||||||
lookup.ligatures.setdefault(components[0], []).append(lig)
|
st.ligatures.setdefault(components[0], []).append(lig)
|
||||||
|
lookup.SubTable.append(st)
|
||||||
|
lookup.LookupFlag = self.lookup_flag
|
||||||
|
lookup.LookupType = self.lookup_type
|
||||||
|
lookup.SubTableCount = len(lookup.SubTable)
|
||||||
return lookup
|
return lookup
|
||||||
|
|
||||||
|
|
||||||
@ -350,6 +362,12 @@ class SingleSubstBuilder(LookupBuilder):
|
|||||||
self.mapping == other.mapping)
|
self.mapping == other.mapping)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
lookup = otTables.SingleSubst()
|
lookup = otTables.Lookup()
|
||||||
lookup.mapping = self.mapping
|
lookup.SubTable = []
|
||||||
|
st = otTables.SingleSubst()
|
||||||
|
st.mapping = self.mapping
|
||||||
|
lookup.SubTable.append(st)
|
||||||
|
lookup.LookupFlag = self.lookup_flag
|
||||||
|
lookup.LookupType = self.lookup_type
|
||||||
|
lookup.SubTableCount = len(lookup.SubTable)
|
||||||
return lookup
|
return lookup
|
||||||
|
33
Lib/fontTools/feaLib/testdata/GSUB_3.ttx
vendored
33
Lib/fontTools/feaLib/testdata/GSUB_3.ttx
vendored
@ -37,20 +37,25 @@
|
|||||||
</FeatureList>
|
</FeatureList>
|
||||||
<LookupList>
|
<LookupList>
|
||||||
<!-- LookupCount=1 -->
|
<!-- LookupCount=1 -->
|
||||||
<AlternateSubst index="0" Format="1">
|
<Lookup index="0">
|
||||||
<AlternateSet glyph="A">
|
<!-- LookupType=3 -->
|
||||||
<Alternate glyph="A.alt1"/>
|
<LookupFlag value="0"/>
|
||||||
<Alternate glyph="A.alt2"/>
|
<!-- SubTableCount=1 -->
|
||||||
</AlternateSet>
|
<AlternateSubst index="0" Format="1">
|
||||||
<AlternateSet glyph="B">
|
<AlternateSet glyph="A">
|
||||||
<Alternate glyph="B.alt1"/>
|
<Alternate glyph="A.alt1"/>
|
||||||
<Alternate glyph="B.alt2"/>
|
<Alternate glyph="A.alt2"/>
|
||||||
<Alternate glyph="B.alt3"/>
|
</AlternateSet>
|
||||||
</AlternateSet>
|
<AlternateSet glyph="B">
|
||||||
<AlternateSet glyph="C">
|
<Alternate glyph="B.alt1"/>
|
||||||
<Alternate glyph="C.alt1"/>
|
<Alternate glyph="B.alt2"/>
|
||||||
</AlternateSet>
|
<Alternate glyph="B.alt3"/>
|
||||||
</AlternateSubst>
|
</AlternateSet>
|
||||||
|
<AlternateSet glyph="C">
|
||||||
|
<Alternate glyph="C.alt1"/>
|
||||||
|
</AlternateSet>
|
||||||
|
</AlternateSubst>
|
||||||
|
</Lookup>
|
||||||
</LookupList>
|
</LookupList>
|
||||||
</GSUB>
|
</GSUB>
|
||||||
|
|
||||||
|
106
Lib/fontTools/feaLib/testdata/language_required.ttx
vendored
106
Lib/fontTools/feaLib/testdata/language_required.ttx
vendored
@ -70,49 +70,69 @@
|
|||||||
</FeatureList>
|
</FeatureList>
|
||||||
<LookupList>
|
<LookupList>
|
||||||
<!-- LookupCount=4 -->
|
<!-- LookupCount=4 -->
|
||||||
<LigatureSubst index="0" Format="1">
|
<Lookup index="0">
|
||||||
<LigatureSet glyph="D">
|
<!-- LookupType=4 -->
|
||||||
<Ligature components="D,E,U" glyph="D_E_U"/>
|
<LookupFlag value="0"/>
|
||||||
</LigatureSet>
|
<!-- SubTableCount=1 -->
|
||||||
</LigatureSubst>
|
<LigatureSubst index="0" Format="1">
|
||||||
<LigatureSubst index="1" Format="1">
|
<LigatureSet glyph="D">
|
||||||
<LigatureSet glyph="F">
|
<Ligature components="D,E,U" glyph="D_E_U"/>
|
||||||
<Ligature components="F,R,A" glyph="D_E_U"/>
|
</LigatureSet>
|
||||||
</LigatureSet>
|
</LigatureSubst>
|
||||||
</LigatureSubst>
|
</Lookup>
|
||||||
<LigatureSubst index="2" Format="1">
|
<Lookup index="1">
|
||||||
<LigatureSet glyph="I">
|
<!-- LookupType=4 -->
|
||||||
<Ligature components="I,T,A" glyph="I_T_A"/>
|
<LookupFlag value="0"/>
|
||||||
</LigatureSet>
|
<!-- SubTableCount=1 -->
|
||||||
</LigatureSubst>
|
<LigatureSubst index="0" Format="1">
|
||||||
<SingleSubst index="3">
|
<LigatureSet glyph="F">
|
||||||
<Substitution in="a" out="A.sc"/>
|
<Ligature components="F,R,A" glyph="D_E_U"/>
|
||||||
<Substitution in="b" out="B.sc"/>
|
</LigatureSet>
|
||||||
<Substitution in="c" out="C.sc"/>
|
</LigatureSubst>
|
||||||
<Substitution in="d" out="D.sc"/>
|
</Lookup>
|
||||||
<Substitution in="e" out="E.sc"/>
|
<Lookup index="2">
|
||||||
<Substitution in="f" out="F.sc"/>
|
<!-- LookupType=4 -->
|
||||||
<Substitution in="g" out="G.sc"/>
|
<LookupFlag value="0"/>
|
||||||
<Substitution in="h" out="H.sc"/>
|
<!-- SubTableCount=1 -->
|
||||||
<Substitution in="i" out="I.sc"/>
|
<LigatureSubst index="0" Format="1">
|
||||||
<Substitution in="j" out="J.sc"/>
|
<LigatureSet glyph="I">
|
||||||
<Substitution in="k" out="K.sc"/>
|
<Ligature components="I,T,A" glyph="I_T_A"/>
|
||||||
<Substitution in="l" out="L.sc"/>
|
</LigatureSet>
|
||||||
<Substitution in="m" out="M.sc"/>
|
</LigatureSubst>
|
||||||
<Substitution in="n" out="N.sc"/>
|
</Lookup>
|
||||||
<Substitution in="o" out="O.sc"/>
|
<Lookup index="3">
|
||||||
<Substitution in="p" out="P.sc"/>
|
<!-- LookupType=1 -->
|
||||||
<Substitution in="q" out="Q.sc"/>
|
<LookupFlag value="0"/>
|
||||||
<Substitution in="r" out="R.sc"/>
|
<!-- SubTableCount=1 -->
|
||||||
<Substitution in="s" out="S.sc"/>
|
<SingleSubst index="0">
|
||||||
<Substitution in="t" out="T.sc"/>
|
<Substitution in="a" out="A.sc"/>
|
||||||
<Substitution in="u" out="U.sc"/>
|
<Substitution in="b" out="B.sc"/>
|
||||||
<Substitution in="v" out="V.sc"/>
|
<Substitution in="c" out="C.sc"/>
|
||||||
<Substitution in="w" out="W.sc"/>
|
<Substitution in="d" out="D.sc"/>
|
||||||
<Substitution in="x" out="X.sc"/>
|
<Substitution in="e" out="E.sc"/>
|
||||||
<Substitution in="y" out="Y.sc"/>
|
<Substitution in="f" out="F.sc"/>
|
||||||
<Substitution in="z" out="Z.sc"/>
|
<Substitution in="g" out="G.sc"/>
|
||||||
</SingleSubst>
|
<Substitution in="h" out="H.sc"/>
|
||||||
|
<Substitution in="i" out="I.sc"/>
|
||||||
|
<Substitution in="j" out="J.sc"/>
|
||||||
|
<Substitution in="k" out="K.sc"/>
|
||||||
|
<Substitution in="l" out="L.sc"/>
|
||||||
|
<Substitution in="m" out="M.sc"/>
|
||||||
|
<Substitution in="n" out="N.sc"/>
|
||||||
|
<Substitution in="o" out="O.sc"/>
|
||||||
|
<Substitution in="p" out="P.sc"/>
|
||||||
|
<Substitution in="q" out="Q.sc"/>
|
||||||
|
<Substitution in="r" out="R.sc"/>
|
||||||
|
<Substitution in="s" out="S.sc"/>
|
||||||
|
<Substitution in="t" out="T.sc"/>
|
||||||
|
<Substitution in="u" out="U.sc"/>
|
||||||
|
<Substitution in="v" out="V.sc"/>
|
||||||
|
<Substitution in="w" out="W.sc"/>
|
||||||
|
<Substitution in="x" out="X.sc"/>
|
||||||
|
<Substitution in="y" out="Y.sc"/>
|
||||||
|
<Substitution in="z" out="Z.sc"/>
|
||||||
|
</SingleSubst>
|
||||||
|
</Lookup>
|
||||||
</LookupList>
|
</LookupList>
|
||||||
</GSUB>
|
</GSUB>
|
||||||
|
|
||||||
|
114
Lib/fontTools/feaLib/testdata/spec4h1.ttx
vendored
114
Lib/fontTools/feaLib/testdata/spec4h1.ttx
vendored
@ -81,53 +81,73 @@
|
|||||||
</FeatureList>
|
</FeatureList>
|
||||||
<LookupList>
|
<LookupList>
|
||||||
<!-- LookupCount=4 -->
|
<!-- LookupCount=4 -->
|
||||||
<SingleSubst index="0">
|
<Lookup index="0">
|
||||||
<Substitution in="a" out="A.sc"/>
|
<!-- LookupType=1 -->
|
||||||
<Substitution in="b" out="B.sc"/>
|
<LookupFlag value="0"/>
|
||||||
<Substitution in="c" out="C.sc"/>
|
<!-- SubTableCount=1 -->
|
||||||
<Substitution in="d" out="D.sc"/>
|
<SingleSubst index="0">
|
||||||
<Substitution in="e" out="E.sc"/>
|
<Substitution in="a" out="A.sc"/>
|
||||||
<Substitution in="f" out="F.sc"/>
|
<Substitution in="b" out="B.sc"/>
|
||||||
<Substitution in="g" out="G.sc"/>
|
<Substitution in="c" out="C.sc"/>
|
||||||
<Substitution in="h" out="H.sc"/>
|
<Substitution in="d" out="D.sc"/>
|
||||||
<Substitution in="i" out="I.sc"/>
|
<Substitution in="e" out="E.sc"/>
|
||||||
<Substitution in="j" out="J.sc"/>
|
<Substitution in="f" out="F.sc"/>
|
||||||
<Substitution in="k" out="K.sc"/>
|
<Substitution in="g" out="G.sc"/>
|
||||||
<Substitution in="l" out="L.sc"/>
|
<Substitution in="h" out="H.sc"/>
|
||||||
<Substitution in="m" out="M.sc"/>
|
<Substitution in="i" out="I.sc"/>
|
||||||
<Substitution in="n" out="N.sc"/>
|
<Substitution in="j" out="J.sc"/>
|
||||||
<Substitution in="o" out="O.sc"/>
|
<Substitution in="k" out="K.sc"/>
|
||||||
<Substitution in="p" out="P.sc"/>
|
<Substitution in="l" out="L.sc"/>
|
||||||
<Substitution in="q" out="Q.sc"/>
|
<Substitution in="m" out="M.sc"/>
|
||||||
<Substitution in="r" out="R.sc"/>
|
<Substitution in="n" out="N.sc"/>
|
||||||
<Substitution in="s" out="S.sc"/>
|
<Substitution in="o" out="O.sc"/>
|
||||||
<Substitution in="t" out="T.sc"/>
|
<Substitution in="p" out="P.sc"/>
|
||||||
<Substitution in="u" out="U.sc"/>
|
<Substitution in="q" out="Q.sc"/>
|
||||||
<Substitution in="v" out="V.sc"/>
|
<Substitution in="r" out="R.sc"/>
|
||||||
<Substitution in="w" out="W.sc"/>
|
<Substitution in="s" out="S.sc"/>
|
||||||
<Substitution in="x" out="X.sc"/>
|
<Substitution in="t" out="T.sc"/>
|
||||||
<Substitution in="y" out="Y.sc"/>
|
<Substitution in="u" out="U.sc"/>
|
||||||
<Substitution in="z" out="Z.sc"/>
|
<Substitution in="v" out="V.sc"/>
|
||||||
</SingleSubst>
|
<Substitution in="w" out="W.sc"/>
|
||||||
<LigatureSubst index="1" Format="1">
|
<Substitution in="x" out="X.sc"/>
|
||||||
<LigatureSet glyph="f">
|
<Substitution in="y" out="Y.sc"/>
|
||||||
<Ligature components="f,f" glyph="f_f"/>
|
<Substitution in="z" out="Z.sc"/>
|
||||||
<Ligature components="f,i" glyph="f_i"/>
|
</SingleSubst>
|
||||||
<Ligature components="f,l" glyph="f_l"/>
|
</Lookup>
|
||||||
</LigatureSet>
|
<Lookup index="1">
|
||||||
</LigatureSubst>
|
<!-- LookupType=4 -->
|
||||||
<LigatureSubst index="2" Format="1">
|
<LookupFlag value="0"/>
|
||||||
<LigatureSet glyph="c">
|
<!-- SubTableCount=1 -->
|
||||||
<Ligature components="c,s" glyph="c_s"/>
|
<LigatureSubst index="0" Format="1">
|
||||||
<Ligature components="c,t" glyph="c_t"/>
|
<LigatureSet glyph="f">
|
||||||
</LigatureSet>
|
<Ligature components="f,f" glyph="f_f"/>
|
||||||
</LigatureSubst>
|
<Ligature components="f,i" glyph="f_i"/>
|
||||||
<LigatureSubst index="3" Format="1">
|
<Ligature components="f,l" glyph="f_l"/>
|
||||||
<LigatureSet glyph="c">
|
</LigatureSet>
|
||||||
<Ligature components="c,h" glyph="c_h"/>
|
</LigatureSubst>
|
||||||
<Ligature components="c,k" glyph="c_k"/>
|
</Lookup>
|
||||||
</LigatureSet>
|
<Lookup index="2">
|
||||||
</LigatureSubst>
|
<!-- LookupType=4 -->
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<LigatureSubst index="0" Format="1">
|
||||||
|
<LigatureSet glyph="c">
|
||||||
|
<Ligature components="c,s" glyph="c_s"/>
|
||||||
|
<Ligature components="c,t" glyph="c_t"/>
|
||||||
|
</LigatureSet>
|
||||||
|
</LigatureSubst>
|
||||||
|
</Lookup>
|
||||||
|
<Lookup index="3">
|
||||||
|
<!-- LookupType=4 -->
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<LigatureSubst index="0" Format="1">
|
||||||
|
<LigatureSet glyph="c">
|
||||||
|
<Ligature components="c,h" glyph="c_h"/>
|
||||||
|
<Ligature components="c,k" glyph="c_k"/>
|
||||||
|
</LigatureSet>
|
||||||
|
</LigatureSubst>
|
||||||
|
</Lookup>
|
||||||
</LookupList>
|
</LookupList>
|
||||||
</GSUB>
|
</GSUB>
|
||||||
|
|
||||||
|
33
Lib/fontTools/feaLib/testdata/spec5d1.ttx
vendored
33
Lib/fontTools/feaLib/testdata/spec5d1.ttx
vendored
@ -37,20 +37,25 @@
|
|||||||
</FeatureList>
|
</FeatureList>
|
||||||
<LookupList>
|
<LookupList>
|
||||||
<!-- LookupCount=1 -->
|
<!-- LookupCount=1 -->
|
||||||
<LigatureSubst index="0" Format="1">
|
<Lookup index="0">
|
||||||
<LigatureSet glyph="one">
|
<!-- LookupType=4 -->
|
||||||
<Ligature components="one,fraction,two" glyph="onehalf"/>
|
<LookupFlag value="0"/>
|
||||||
<Ligature components="one,fraction,two.oldstyle" glyph="onehalf"/>
|
<!-- SubTableCount=1 -->
|
||||||
<Ligature components="one,slash,two" glyph="onehalf"/>
|
<LigatureSubst index="0" Format="1">
|
||||||
<Ligature components="one,slash,two.oldstyle" glyph="onehalf"/>
|
<LigatureSet glyph="one">
|
||||||
</LigatureSet>
|
<Ligature components="one,fraction,two" glyph="onehalf"/>
|
||||||
<LigatureSet glyph="one.oldstyle">
|
<Ligature components="one,fraction,two.oldstyle" glyph="onehalf"/>
|
||||||
<Ligature components="one.oldstyle,fraction,two" glyph="onehalf"/>
|
<Ligature components="one,slash,two" glyph="onehalf"/>
|
||||||
<Ligature components="one.oldstyle,fraction,two.oldstyle" glyph="onehalf"/>
|
<Ligature components="one,slash,two.oldstyle" glyph="onehalf"/>
|
||||||
<Ligature components="one.oldstyle,slash,two" glyph="onehalf"/>
|
</LigatureSet>
|
||||||
<Ligature components="one.oldstyle,slash,two.oldstyle" glyph="onehalf"/>
|
<LigatureSet glyph="one.oldstyle">
|
||||||
</LigatureSet>
|
<Ligature components="one.oldstyle,fraction,two" glyph="onehalf"/>
|
||||||
</LigatureSubst>
|
<Ligature components="one.oldstyle,fraction,two.oldstyle" glyph="onehalf"/>
|
||||||
|
<Ligature components="one.oldstyle,slash,two" glyph="onehalf"/>
|
||||||
|
<Ligature components="one.oldstyle,slash,two.oldstyle" glyph="onehalf"/>
|
||||||
|
</LigatureSet>
|
||||||
|
</LigatureSubst>
|
||||||
|
</Lookup>
|
||||||
</LookupList>
|
</LookupList>
|
||||||
</GSUB>
|
</GSUB>
|
||||||
|
|
||||||
|
25
Lib/fontTools/feaLib/testdata/spec5d2.ttx
vendored
25
Lib/fontTools/feaLib/testdata/spec5d2.ttx
vendored
@ -37,16 +37,21 @@
|
|||||||
</FeatureList>
|
</FeatureList>
|
||||||
<LookupList>
|
<LookupList>
|
||||||
<!-- LookupCount=1 -->
|
<!-- LookupCount=1 -->
|
||||||
<LigatureSubst index="0" Format="1">
|
<Lookup index="0">
|
||||||
<LigatureSet glyph="f">
|
<!-- LookupType=4 -->
|
||||||
<Ligature components="f,f,i" glyph="f_f_i"/>
|
<LookupFlag value="0"/>
|
||||||
<Ligature components="f,f" glyph="f_f"/>
|
<!-- SubTableCount=1 -->
|
||||||
<Ligature components="f,i" glyph="f_i"/>
|
<LigatureSubst index="0" Format="1">
|
||||||
</LigatureSet>
|
<LigatureSet glyph="f">
|
||||||
<LigatureSet glyph="o">
|
<Ligature components="f,f,i" glyph="f_f_i"/>
|
||||||
<Ligature components="o,f,f,i" glyph="o_f_f_i"/>
|
<Ligature components="f,f" glyph="f_f"/>
|
||||||
</LigatureSet>
|
<Ligature components="f,i" glyph="f_i"/>
|
||||||
</LigatureSubst>
|
</LigatureSet>
|
||||||
|
<LigatureSet glyph="o">
|
||||||
|
<Ligature components="o,f,f,i" glyph="o_f_f_i"/>
|
||||||
|
</LigatureSet>
|
||||||
|
</LigatureSubst>
|
||||||
|
</Lookup>
|
||||||
</LookupList>
|
</LookupList>
|
||||||
</GSUB>
|
</GSUB>
|
||||||
|
|
||||||
|
@ -120,8 +120,8 @@ class BaseConverter(object):
|
|||||||
raise NotImplementedError(self)
|
raise NotImplementedError(self)
|
||||||
|
|
||||||
def writeArray(self, writer, font, tableDict, values):
|
def writeArray(self, writer, font, tableDict, values):
|
||||||
for i in range(len(values)):
|
for i, value in enumerate(values):
|
||||||
self.write(writer, font, tableDict, values[i], i)
|
self.write(writer, font, tableDict, value, i)
|
||||||
|
|
||||||
def write(self, writer, font, tableDict, value, repeatIndex=None):
|
def write(self, writer, font, tableDict, value, repeatIndex=None):
|
||||||
"""Write a value to the writer."""
|
"""Write a value to the writer."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user