instancer_test: test instancing HVAR table
Aldo added AdvWidthMap to PartialInstancer-VF.ttx test font
This commit is contained in:
parent
c5ec06d82f
commit
2a1e6a1fd5
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.39">
|
||||
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.40">
|
||||
|
||||
<GlyphOrder>
|
||||
<!-- The 'id' attribute is only for humans; it is ignored when parsed. -->
|
||||
@ -12,12 +12,12 @@
|
||||
<!-- Most of this table will be recalculated by the compiler -->
|
||||
<tableVersion value="1.0"/>
|
||||
<fontRevision value="2.001"/>
|
||||
<checkSumAdjustment value="0x9184e88f"/>
|
||||
<checkSumAdjustment value="0x9180a393"/>
|
||||
<magicNumber value="0x5f0f3cf5"/>
|
||||
<flags value="00000000 00000011"/>
|
||||
<unitsPerEm value="1000"/>
|
||||
<created value="Tue Mar 5 00:05:14 2019"/>
|
||||
<modified value="Sat Apr 20 14:38:56 2019"/>
|
||||
<modified value="Sat Apr 20 17:03:24 2019"/>
|
||||
<xMin value="40"/>
|
||||
<yMin value="-200"/>
|
||||
<xMax value="450"/>
|
||||
@ -570,7 +570,7 @@
|
||||
</VarRegionList>
|
||||
<!-- VarDataCount=1 -->
|
||||
<VarData index="0">
|
||||
<!-- ItemCount=3 -->
|
||||
<!-- ItemCount=2 -->
|
||||
<NumShorts value="0"/>
|
||||
<!-- VarRegionCount=5 -->
|
||||
<VarRegionIndex index="0" value="2"/>
|
||||
@ -578,11 +578,15 @@
|
||||
<VarRegionIndex index="2" value="4"/>
|
||||
<VarRegionIndex index="3" value="5"/>
|
||||
<VarRegionIndex index="4" value="6"/>
|
||||
<Item index="0" value="[0, 0, 0, 0, 0]"/>
|
||||
<Item index="1" value="[-4, -48, -11, 31, 55]"/>
|
||||
<Item index="2" value="[0, 0, 0, 0, 0]"/>
|
||||
<Item index="0" value="[-4, -48, -11, 31, 55]"/>
|
||||
<Item index="1" value="[0, 0, 0, 0, 0]"/>
|
||||
</VarData>
|
||||
</VarStore>
|
||||
<AdvWidthMap>
|
||||
<Map glyph=".notdef" outer="0" inner="1"/>
|
||||
<Map glyph="hyphen" outer="0" inner="0"/>
|
||||
<Map glyph="space" outer="0" inner="1"/>
|
||||
</AdvWidthMap>
|
||||
</HVAR>
|
||||
|
||||
<MVAR>
|
||||
|
@ -277,6 +277,62 @@ class InstantiateMVARTest(object):
|
||||
assert "MVAR" not in varfont
|
||||
|
||||
|
||||
class InstantiateHVARTest(object):
|
||||
# the 'expectedDeltas' below refer to the VarData item deltas for the "hyphen"
|
||||
# glyph in the PartialInstancerTest-VF.ttx test font, that are left after
|
||||
# partial instancing
|
||||
@pytest.mark.parametrize(
|
||||
"location, expectedRegions, expectedDeltas",
|
||||
[
|
||||
({"wght": -1.0}, [{"wdth": (-1.0, -1.0, 0)}], [-59]),
|
||||
({"wght": 0}, [{"wdth": (-1.0, -1.0, 0)}], [-48]),
|
||||
({"wght": 1.0}, [{"wdth": (-1.0, -1.0, 0)}], [7]),
|
||||
(
|
||||
{"wdth": -1.0},
|
||||
[
|
||||
{"wght": (-1.0, -1.0, 0.0)},
|
||||
{"wght": (0.0, 0.61, 1.0)},
|
||||
{"wght": (0.61, 1.0, 1.0)},
|
||||
],
|
||||
[-11, 31, 51],
|
||||
),
|
||||
({"wdth": 0}, [{"wght": (0.61, 1.0, 1.0)}], [-4]),
|
||||
],
|
||||
)
|
||||
def test_partial_instance(
|
||||
self, varfont, fvarAxes, location, expectedRegions, expectedDeltas
|
||||
):
|
||||
instancer.instantiateHVAR(varfont, location)
|
||||
|
||||
assert "HVAR" in varfont
|
||||
hvar = varfont["HVAR"].table
|
||||
varStore = hvar.VarStore
|
||||
|
||||
regions = varStore.VarRegionList.Region
|
||||
assert [reg.get_support(fvarAxes) for reg in regions] == expectedRegions
|
||||
|
||||
assert len(varStore.VarData) == 1
|
||||
assert varStore.VarData[0].ItemCount == 2
|
||||
|
||||
assert hvar.AdvWidthMap is not None
|
||||
advWithMap = hvar.AdvWidthMap.mapping
|
||||
|
||||
assert advWithMap[".notdef"] == advWithMap["space"]
|
||||
varIdx = advWithMap[".notdef"]
|
||||
# these glyphs have no metrics variations in the test font
|
||||
assert varStore.VarData[varIdx >> 16].Item[varIdx & 0xFFFF] == (
|
||||
[0] * varStore.VarData[0].VarRegionCount
|
||||
)
|
||||
|
||||
varIdx = advWithMap["hyphen"]
|
||||
assert varStore.VarData[varIdx >> 16].Item[varIdx & 0xFFFF] == expectedDeltas
|
||||
|
||||
def test_full_instance(self, varfont):
|
||||
instancer.instantiateHVAR(varfont, {"wght": 0, "wdth": 0})
|
||||
|
||||
assert "HVAR" not in varfont
|
||||
|
||||
|
||||
class InstantiateItemVariationStoreTest(object):
|
||||
def test_VarRegion_get_support(self):
|
||||
axisOrder = ["wght", "wdth", "opsz"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user