Merge pull request #3520 from fonttools/dedup-lkp-refs
[feaLib] don't reference same lookup multiple times within the same feature
This commit is contained in:
commit
91775d2205
@ -880,8 +880,13 @@ class Builder(object):
|
|||||||
# l.lookup_index will be None when a lookup is not needed
|
# l.lookup_index will be None when a lookup is not needed
|
||||||
# for the table under construction. For example, substitution
|
# for the table under construction. For example, substitution
|
||||||
# rules will have no lookup_index while building GPOS tables.
|
# rules will have no lookup_index while building GPOS tables.
|
||||||
|
# We also deduplicate lookup indices, as they only get applied once
|
||||||
|
# within a given feature:
|
||||||
|
# https://github.com/fonttools/fonttools/issues/2946
|
||||||
lookup_indices = tuple(
|
lookup_indices = tuple(
|
||||||
[l.lookup_index for l in lookups if l.lookup_index is not None]
|
dict.fromkeys(
|
||||||
|
l.lookup_index for l in lookups if l.lookup_index is not None
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
size_feature = tag == "GPOS" and feature_tag == "size"
|
size_feature = tag == "GPOS" and feature_tag == "size"
|
||||||
|
@ -81,7 +81,7 @@ class BuilderTest(unittest.TestCase):
|
|||||||
MultipleLookupsPerGlyph MultipleLookupsPerGlyph2 GSUB_6_formats
|
MultipleLookupsPerGlyph MultipleLookupsPerGlyph2 GSUB_6_formats
|
||||||
GSUB_5_formats delete_glyph STAT_test STAT_test_elidedFallbackNameID
|
GSUB_5_formats delete_glyph STAT_test STAT_test_elidedFallbackNameID
|
||||||
variable_scalar_valuerecord variable_scalar_anchor variable_conditionset
|
variable_scalar_valuerecord variable_scalar_anchor variable_conditionset
|
||||||
variable_mark_anchor
|
variable_mark_anchor duplicate_lookup_reference
|
||||||
""".split()
|
""".split()
|
||||||
|
|
||||||
VARFONT_AXES = [
|
VARFONT_AXES = [
|
||||||
|
18
Tests/feaLib/data/duplicate_lookup_reference.fea
Normal file
18
Tests/feaLib/data/duplicate_lookup_reference.fea
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# https://github.com/fonttools/fonttools/issues/2946
|
||||||
|
|
||||||
|
languagesystem DFLT dflt;
|
||||||
|
languagesystem latn dflt;
|
||||||
|
|
||||||
|
feature test {
|
||||||
|
lookup alt1 {
|
||||||
|
sub a by A;
|
||||||
|
} alt1;
|
||||||
|
lookup alt2 {
|
||||||
|
sub b by B;
|
||||||
|
} alt2;
|
||||||
|
|
||||||
|
|
||||||
|
script latn;
|
||||||
|
lookup alt1;
|
||||||
|
|
||||||
|
} test;
|
63
Tests/feaLib/data/duplicate_lookup_reference.ttx
Normal file
63
Tests/feaLib/data/duplicate_lookup_reference.ttx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ttFont>
|
||||||
|
|
||||||
|
<GSUB>
|
||||||
|
<Version value="0x00010000"/>
|
||||||
|
<ScriptList>
|
||||||
|
<!-- ScriptCount=2 -->
|
||||||
|
<ScriptRecord index="0">
|
||||||
|
<ScriptTag value="DFLT"/>
|
||||||
|
<Script>
|
||||||
|
<DefaultLangSys>
|
||||||
|
<ReqFeatureIndex value="65535"/>
|
||||||
|
<!-- FeatureCount=1 -->
|
||||||
|
<FeatureIndex index="0" value="0"/>
|
||||||
|
</DefaultLangSys>
|
||||||
|
<!-- LangSysCount=0 -->
|
||||||
|
</Script>
|
||||||
|
</ScriptRecord>
|
||||||
|
<ScriptRecord index="1">
|
||||||
|
<ScriptTag value="latn"/>
|
||||||
|
<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=2 -->
|
||||||
|
<LookupListIndex index="0" value="0"/>
|
||||||
|
<LookupListIndex index="1" value="1"/>
|
||||||
|
</Feature>
|
||||||
|
</FeatureRecord>
|
||||||
|
</FeatureList>
|
||||||
|
<LookupList>
|
||||||
|
<!-- LookupCount=2 -->
|
||||||
|
<Lookup index="0">
|
||||||
|
<LookupType value="1"/>
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<SingleSubst index="0">
|
||||||
|
<Substitution in="a" out="A"/>
|
||||||
|
</SingleSubst>
|
||||||
|
</Lookup>
|
||||||
|
<Lookup index="1">
|
||||||
|
<LookupType value="1"/>
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<SingleSubst index="0">
|
||||||
|
<Substitution in="b" out="B"/>
|
||||||
|
</SingleSubst>
|
||||||
|
</Lookup>
|
||||||
|
</LookupList>
|
||||||
|
</GSUB>
|
||||||
|
|
||||||
|
</ttFont>
|
Loading…
x
Reference in New Issue
Block a user