Allow multiple value record types in the same pairpos table (#2776)
* Use buildPairPosClassesSubtable's ability to promote value records (see #2772) * Add tests for #2772
This commit is contained in:
parent
5d5c16207b
commit
64fd837ca1
@ -1387,27 +1387,16 @@ class PairPosBuilder(LookupBuilder):
|
||||
lookup.
|
||||
"""
|
||||
builders = {}
|
||||
builder = None
|
||||
builder = ClassPairPosSubtableBuilder(self)
|
||||
for glyphclass1, value1, glyphclass2, value2 in self.pairs:
|
||||
if glyphclass1 is self.SUBTABLE_BREAK_:
|
||||
if builder is not None:
|
||||
builder.addSubtableBreak()
|
||||
builder.addSubtableBreak()
|
||||
continue
|
||||
valFormat1, valFormat2 = 0, 0
|
||||
if value1:
|
||||
valFormat1 = value1.getFormat()
|
||||
if value2:
|
||||
valFormat2 = value2.getFormat()
|
||||
builder = builders.get((valFormat1, valFormat2))
|
||||
if builder is None:
|
||||
builder = ClassPairPosSubtableBuilder(self)
|
||||
builders[(valFormat1, valFormat2)] = builder
|
||||
builder.addPair(glyphclass1, value1, glyphclass2, value2)
|
||||
subtables = []
|
||||
if self.glyphPairs:
|
||||
subtables.extend(buildPairPosGlyphs(self.glyphPairs, self.glyphMap))
|
||||
for key in sorted(builders.keys()):
|
||||
subtables.extend(builders[key].subtables())
|
||||
subtables.extend(builder.subtables())
|
||||
lookup = self.buildLookup_(subtables)
|
||||
|
||||
# Compact the lookup
|
||||
|
@ -69,7 +69,7 @@ class BuilderTest(unittest.TestCase):
|
||||
spec9a spec9b spec9c1 spec9c2 spec9c3 spec9d spec9e spec9f spec9g
|
||||
spec10
|
||||
bug453 bug457 bug463 bug501 bug502 bug504 bug505 bug506 bug509
|
||||
bug512 bug514 bug568 bug633 bug1307 bug1459 bug2276
|
||||
bug512 bug514 bug568 bug633 bug1307 bug1459 bug2276 variable_bug2772
|
||||
name size size2 multiple_feature_blocks omitted_GlyphClassDef
|
||||
ZeroValue_SinglePos_horizontal ZeroValue_SinglePos_vertical
|
||||
ZeroValue_PairPos_horizontal ZeroValue_PairPos_vertical
|
||||
|
4
Tests/feaLib/data/variable_bug2772.fea
Normal file
4
Tests/feaLib/data/variable_bug2772.fea
Normal file
@ -0,0 +1,4 @@
|
||||
feature kern {
|
||||
pos [p] g -5;
|
||||
pos [p] y (wght=1000:-100 wght=200:0);
|
||||
} kern;
|
103
Tests/feaLib/data/variable_bug2772.ttx
Normal file
103
Tests/feaLib/data/variable_bug2772.ttx
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="4.37">
|
||||
|
||||
<GDEF>
|
||||
<Version value="0x00010003"/>
|
||||
<VarStore Format="1">
|
||||
<Format value="1"/>
|
||||
<VarRegionList>
|
||||
<!-- RegionAxisCount=2 -->
|
||||
<!-- RegionCount=1 -->
|
||||
<Region index="0">
|
||||
<VarRegionAxis index="0">
|
||||
<StartCoord value="0.0"/>
|
||||
<PeakCoord value="1.0"/>
|
||||
<EndCoord value="1.0"/>
|
||||
</VarRegionAxis>
|
||||
<VarRegionAxis index="1">
|
||||
<StartCoord value="0.0"/>
|
||||
<PeakCoord value="0.0"/>
|
||||
<EndCoord value="0.0"/>
|
||||
</VarRegionAxis>
|
||||
</Region>
|
||||
</VarRegionList>
|
||||
<!-- VarDataCount=1 -->
|
||||
<VarData index="0">
|
||||
<!-- ItemCount=1 -->
|
||||
<NumShorts value="0"/>
|
||||
<!-- VarRegionCount=1 -->
|
||||
<VarRegionIndex index="0" value="0"/>
|
||||
<Item index="0" value="[-100]"/>
|
||||
</VarData>
|
||||
</VarStore>
|
||||
</GDEF>
|
||||
|
||||
<GPOS>
|
||||
<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="kern"/>
|
||||
<Feature>
|
||||
<!-- LookupCount=1 -->
|
||||
<LookupListIndex index="0" value="0"/>
|
||||
</Feature>
|
||||
</FeatureRecord>
|
||||
</FeatureList>
|
||||
<LookupList>
|
||||
<!-- LookupCount=1 -->
|
||||
<Lookup index="0">
|
||||
<LookupType value="2"/>
|
||||
<LookupFlag value="0"/>
|
||||
<!-- SubTableCount=1 -->
|
||||
<PairPos index="0" Format="2">
|
||||
<Coverage>
|
||||
<Glyph value="p"/>
|
||||
</Coverage>
|
||||
<ValueFormat1 value="68"/>
|
||||
<ValueFormat2 value="0"/>
|
||||
<ClassDef1>
|
||||
</ClassDef1>
|
||||
<ClassDef2>
|
||||
<ClassDef glyph="g" class="2"/>
|
||||
<ClassDef glyph="y" class="1"/>
|
||||
</ClassDef2>
|
||||
<!-- Class1Count=1 -->
|
||||
<!-- Class2Count=3 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="0">
|
||||
<XAdvDevice>
|
||||
<StartSize value="0"/>
|
||||
<EndSize value="0"/>
|
||||
<DeltaFormat value="32768"/>
|
||||
</XAdvDevice>
|
||||
</Value1>
|
||||
</Class2Record>
|
||||
<Class2Record index="2">
|
||||
<Value1 XAdvance="-5"/>
|
||||
</Class2Record>
|
||||
</Class1Record>
|
||||
</PairPos>
|
||||
</Lookup>
|
||||
</LookupList>
|
||||
</GPOS>
|
||||
|
||||
</ttFont>
|
Loading…
x
Reference in New Issue
Block a user