Merge pull request #2229 from fonttools/varLib-otlLib-noreload
[varLib/otlLib] Allow merging into VariationFont without first saving GPOS PairPos2
This commit is contained in:
commit
2089d05126
@ -2075,8 +2075,8 @@ def buildPairPosClassesSubtable(pairs, glyphMap, valueFormat1=None, valueFormat2
|
||||
classDef2.add(gc2)
|
||||
self = ot.PairPos()
|
||||
self.Format = 2
|
||||
self.ValueFormat1 = _getValueFormat(valueFormat1, pairs.values(), 0)
|
||||
self.ValueFormat2 = _getValueFormat(valueFormat2, pairs.values(), 1)
|
||||
valueFormat1 = self.ValueFormat1 = _getValueFormat(valueFormat1, pairs.values(), 0)
|
||||
valueFormat2 = self.ValueFormat2 = _getValueFormat(valueFormat2, pairs.values(), 1)
|
||||
self.Coverage = buildCoverage(coverage, glyphMap)
|
||||
self.ClassDef1 = classDef1.build()
|
||||
self.ClassDef2 = classDef2.build()
|
||||
@ -2090,6 +2090,8 @@ def buildPairPosClassesSubtable(pairs, glyphMap, valueFormat1=None, valueFormat2
|
||||
for c2 in classes2:
|
||||
rec2 = ot.Class2Record()
|
||||
rec2.Value1, rec2.Value2 = pairs.get((c1, c2), (None, None))
|
||||
if valueFormat1 and rec2.Value1 is None: rec2.Value1 = ValueRecord(valueFormat1)
|
||||
if valueFormat2 and rec2.Value2 is None: rec2.Value2 = ValueRecord(valueFormat2)
|
||||
rec1.Class2Record.append(rec2)
|
||||
self.Class1Count = len(self.Class1Record)
|
||||
self.Class2Count = len(classes2)
|
||||
@ -2174,8 +2176,8 @@ def buildPairPosGlyphsSubtable(pairs, glyphMap, valueFormat1=None, valueFormat2=
|
||||
"""
|
||||
self = ot.PairPos()
|
||||
self.Format = 1
|
||||
self.ValueFormat1 = _getValueFormat(valueFormat1, pairs.values(), 0)
|
||||
self.ValueFormat2 = _getValueFormat(valueFormat2, pairs.values(), 1)
|
||||
valueFormat1 = self.ValueFormat1 = _getValueFormat(valueFormat1, pairs.values(), 0)
|
||||
valueFormat2 = self.ValueFormat2 = _getValueFormat(valueFormat2, pairs.values(), 1)
|
||||
p = {}
|
||||
for (glyphA, glyphB), (valA, valB) in pairs.items():
|
||||
p.setdefault(glyphA, []).append((glyphB, valA, valB))
|
||||
@ -2188,8 +2190,8 @@ def buildPairPosGlyphsSubtable(pairs, glyphMap, valueFormat1=None, valueFormat2=
|
||||
for glyph2, val1, val2 in sorted(p[glyph], key=lambda x: glyphMap[x[0]]):
|
||||
pvr = ot.PairValueRecord()
|
||||
pvr.SecondGlyph = glyph2
|
||||
pvr.Value1 = val1 if val1 and val1.getFormat() != 0 else None
|
||||
pvr.Value2 = val2 if val2 and val2.getFormat() != 0 else None
|
||||
pvr.Value1 = val1 if valueFormat1 else None
|
||||
pvr.Value2 = val2 if valueFormat2 else None
|
||||
ps.PairValueRecord.append(pvr)
|
||||
ps.PairValueCount = len(ps.PairValueRecord)
|
||||
self.PairSetCount = len(self.PairSet)
|
||||
|
@ -9,7 +9,6 @@ from fontTools.otlLib.maxContextCalc import maxCtxFont
|
||||
from fontTools.pens.basePen import NullPen
|
||||
from fontTools.misc.loggingTools import Timer
|
||||
from fontTools.subset.cff import *
|
||||
from fontTools.varLib import varStore
|
||||
import sys
|
||||
import struct
|
||||
import array
|
||||
@ -1877,7 +1876,7 @@ def subset_glyphs(self, s):
|
||||
table.RsbMap.mapping = _dict_subset(table.RsbMap.mapping, s.glyphs)
|
||||
used.update(table.RsbMap.mapping.values())
|
||||
|
||||
varidx_map = varStore.VarStore_subset_varidxes(table.VarStore, used, retainFirstMap=retainAdvMap, advIdxes=advIdxes_)
|
||||
varidx_map = table.VarStore.subset_varidxes(used, retainFirstMap=retainAdvMap, advIdxes=advIdxes_)
|
||||
|
||||
if table.AdvWidthMap:
|
||||
table.AdvWidthMap.mapping = _remap_index_map(s, varidx_map, table.AdvWidthMap)
|
||||
@ -1915,7 +1914,7 @@ def subset_glyphs(self, s):
|
||||
table.VOrgMap.mapping = _dict_subset(table.VOrgMap.mapping, s.glyphs)
|
||||
used.update(table.VOrgMap.mapping.values())
|
||||
|
||||
varidx_map = varStore.VarStore_subset_varidxes(table.VarStore, used, retainFirstMap=retainAdvMap, advIdxes=advIdxes_)
|
||||
varidx_map = table.VarStore.subset_varidxes(used, retainFirstMap=retainAdvMap, advIdxes=advIdxes_)
|
||||
|
||||
if table.AdvHeightMap:
|
||||
table.AdvHeightMap.mapping = _remap_index_map(s, varidx_map, table.AdvHeightMap)
|
||||
|
@ -636,7 +636,7 @@ class TTFont(object):
|
||||
log.debug("reusing '%s' table", tag)
|
||||
writer.setEntry(tag, entry)
|
||||
return
|
||||
log.debug("writing '%s' table to disk", tag)
|
||||
log.debug("Writing '%s' table to disk", tag)
|
||||
writer[tag] = tabledata
|
||||
if tableCache is not None:
|
||||
tableCache[(Tag(tag), tabledata)] = writer[tag]
|
||||
@ -646,7 +646,7 @@ class TTFont(object):
|
||||
"""
|
||||
tag = Tag(tag)
|
||||
if self.isLoaded(tag):
|
||||
log.debug("compiling '%s' table", tag)
|
||||
log.debug("Compiling '%s' table", tag)
|
||||
return self.tables[tag].compile(self)
|
||||
elif self.reader and tag in self.reader:
|
||||
log.debug("Reading '%s' table from disk", tag)
|
||||
|
@ -76,6 +76,7 @@
|
||||
<!-- Class2Count=2 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="-26"/>
|
||||
|
@ -50,6 +50,7 @@
|
||||
<!-- Class2Count=2 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="1"/>
|
||||
@ -79,6 +80,7 @@
|
||||
<!-- Class2Count=3 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="4"/>
|
||||
@ -89,8 +91,10 @@
|
||||
</Class1Record>
|
||||
<Class1Record index="1">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="2">
|
||||
<Value1 XAdvance="2"/>
|
||||
@ -114,6 +118,7 @@
|
||||
<!-- Class2Count=2 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XPlacement="0" YPlacement="0" XAdvance="0" YAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XPlacement="5" YPlacement="5" XAdvance="5" YAdvance="5"/>
|
||||
|
@ -76,6 +76,7 @@
|
||||
<!-- Class2Count=2 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="-12"/>
|
||||
@ -105,8 +106,10 @@
|
||||
<!-- Class2Count=3 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="2">
|
||||
<Value1 XAdvance="-20"/>
|
||||
@ -114,11 +117,13 @@
|
||||
</Class1Record>
|
||||
<Class1Record index="1">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="-10"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="2">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
</Class1Record>
|
||||
</PairPos>
|
||||
|
@ -52,6 +52,7 @@
|
||||
<!-- Class2Count=3 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="0"/>
|
||||
|
@ -91,6 +91,7 @@
|
||||
<!-- Class2Count=2 -->
|
||||
<Class1Record index="0">
|
||||
<Class2Record index="0">
|
||||
<Value1 XAdvance="0"/>
|
||||
</Class2Record>
|
||||
<Class2Record index="1">
|
||||
<Value1 XAdvance="-100"/>
|
||||
|
@ -839,8 +839,12 @@ class BuilderTest(object):
|
||||
" <!-- Class2Count=3 -->",
|
||||
' <Class1Record index="0">',
|
||||
' <Class2Record index="0">',
|
||||
' <Value1 XPlacement="0" YPlacement="0"/>',
|
||||
' <Value2 XPlacement="0"/>',
|
||||
" </Class2Record>",
|
||||
' <Class2Record index="1">',
|
||||
' <Value1 XPlacement="0" YPlacement="0"/>',
|
||||
' <Value2 XPlacement="0"/>',
|
||||
" </Class2Record>",
|
||||
' <Class2Record index="2">',
|
||||
' <Value1 XPlacement="-80" YPlacement="-20"/>',
|
||||
@ -849,8 +853,11 @@ class BuilderTest(object):
|
||||
" </Class1Record>",
|
||||
' <Class1Record index="1">',
|
||||
' <Class2Record index="0">',
|
||||
' <Value1 XPlacement="0" YPlacement="0"/>',
|
||||
' <Value2 XPlacement="0"/>',
|
||||
" </Class2Record>",
|
||||
' <Class2Record index="1">',
|
||||
' <Value1 XPlacement="0" YPlacement="0"/>',
|
||||
' <Value2 XPlacement="-20"/>',
|
||||
" </Class2Record>",
|
||||
' <Class2Record index="2">',
|
||||
@ -911,6 +918,7 @@ class BuilderTest(object):
|
||||
("A", "zero"): (d0, d50),
|
||||
("A", "one"): (None, d20),
|
||||
("B", "five"): (d8020, d50),
|
||||
|
||||
},
|
||||
self.GLYPHMAP,
|
||||
)
|
||||
@ -927,6 +935,7 @@ class BuilderTest(object):
|
||||
" <!-- PairValueCount=2 -->",
|
||||
' <PairValueRecord index="0">',
|
||||
' <SecondGlyph value="zero"/>',
|
||||
' <Value1/>',
|
||||
' <Value2 XPlacement="-50"/>',
|
||||
" </PairValueRecord>",
|
||||
' <PairValueRecord index="1">',
|
||||
|
Loading…
x
Reference in New Issue
Block a user