[varLib/avar2] Add compile test
This commit is contained in:
parent
aabb26ed69
commit
ff7f49a94c
@ -257,8 +257,8 @@ def _add_avar(font, axes, mappings, axisTags):
|
|||||||
varIdxes = {axis: optimized[value] for axis, value in varIdxes.items()}
|
varIdxes = {axis: optimized[value] for axis, value in varIdxes.items()}
|
||||||
|
|
||||||
varIdxMap = ot.DeltaSetIndexMap()
|
varIdxMap = ot.DeltaSetIndexMap()
|
||||||
varIdxMap.Format = 1
|
|
||||||
varIdxMap.mapping = [varIdxes[t] for t in axisTags]
|
varIdxMap.mapping = [varIdxes[t] for t in axisTags]
|
||||||
|
varIdxMap.Format = 1 if len(varIdxMap.mapping) > 0xFFFF else 0
|
||||||
|
|
||||||
avar.majorVersion = 2
|
avar.majorVersion = 2
|
||||||
avar.table = ot.avar()
|
avar.table = ot.avar()
|
||||||
|
62
Tests/varLib/data/BuildAvar2.designspace
Normal file
62
Tests/varLib/data/BuildAvar2.designspace
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<designspace format="3">
|
||||||
|
<axes>
|
||||||
|
<axis default="400.0" maximum="900.0" minimum="100.0" name="weight" tag="wght">
|
||||||
|
<map input="100.0" output="26" />
|
||||||
|
<map input="200.0" output="39" />
|
||||||
|
<map input="300.0" output="58" />
|
||||||
|
<map input="400.0" output="90" />
|
||||||
|
<map input="500.0" output="108" />
|
||||||
|
<map input="600.0" output="128" />
|
||||||
|
<map input="700.0" output="151" />
|
||||||
|
<map input="800.0" output="169" />
|
||||||
|
<map input="900.0" output="190" />
|
||||||
|
<labelname xml:lang="en">Weight</labelname>
|
||||||
|
</axis>
|
||||||
|
<mappings>
|
||||||
|
<mapping>
|
||||||
|
<input>
|
||||||
|
<dimension name="weight" xvalue="90"/>
|
||||||
|
</input>
|
||||||
|
<output>
|
||||||
|
</output>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<input>
|
||||||
|
<dimension name="weight" xvalue="128"/>
|
||||||
|
</input>
|
||||||
|
<output>
|
||||||
|
<dimension name="weight" xvalue="138"/>
|
||||||
|
</output>
|
||||||
|
</mapping>
|
||||||
|
</mappings>
|
||||||
|
</axes>
|
||||||
|
<sources>
|
||||||
|
<source familyname="Test Family 3" filename="master_ufo/TestFamily3-Light.ufo" name="Test Family 3 Light" stylename="Light">
|
||||||
|
<location>
|
||||||
|
<dimension name="weight" xvalue="26.000000" />
|
||||||
|
</location>
|
||||||
|
</source>
|
||||||
|
<source familyname="Test Family 3" filename="master_ufo/TestFamily3-Regular.ufo" name="Test Family 3 Regular" stylename="Regular">
|
||||||
|
<lib copy="1" />
|
||||||
|
<groups copy="1" />
|
||||||
|
<features copy="1" />
|
||||||
|
<info copy="1" />
|
||||||
|
<location>
|
||||||
|
<dimension name="weight" xvalue="90.000000" />
|
||||||
|
</location>
|
||||||
|
</source>
|
||||||
|
<source familyname="Test Family 3" filename="master_ufo/TestFamily3-SemiBold.ufo" name="Test Family 3 SemiBold" stylename="SemiBold">
|
||||||
|
<location>
|
||||||
|
<dimension name="weight" xvalue="151.000000" />
|
||||||
|
</location>
|
||||||
|
</source>
|
||||||
|
<source familyname="Test Family 3" filename="master_ufo/TestFamily3-Bold.ufo" name="Test Family 3 Bold" stylename="Bold">
|
||||||
|
<location>
|
||||||
|
<dimension name="weight" xvalue="190.000000" />
|
||||||
|
</location>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
<instances>
|
||||||
|
</instances>
|
||||||
|
</designspace>
|
45
Tests/varLib/data/test_results/BuildAvar2.ttx
Normal file
45
Tests/varLib/data/test_results/BuildAvar2.ttx
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.14">
|
||||||
|
|
||||||
|
<avar>
|
||||||
|
<version major="2" minor="0"/>
|
||||||
|
<segment axis="wght">
|
||||||
|
<mapping from="-1.0" to="-1.0"/>
|
||||||
|
<mapping from="-0.6667" to="-0.7969"/>
|
||||||
|
<mapping from="-0.3333" to="-0.5"/>
|
||||||
|
<mapping from="0.0" to="0.0"/>
|
||||||
|
<mapping from="0.2" to="0.18"/>
|
||||||
|
<mapping from="0.4" to="0.38"/>
|
||||||
|
<mapping from="0.6" to="0.61"/>
|
||||||
|
<mapping from="0.8" to="0.79"/>
|
||||||
|
<mapping from="1.0" to="1.0"/>
|
||||||
|
</segment>
|
||||||
|
<VarIdxMap Format="0">
|
||||||
|
<!-- Omitted values default to 0xFFFF/0xFFFF (no variations) -->
|
||||||
|
<Map index="0" outer="0" inner="0"/>
|
||||||
|
</VarIdxMap>
|
||||||
|
<VarStore Format="1">
|
||||||
|
<Format value="1"/>
|
||||||
|
<VarRegionList>
|
||||||
|
<!-- RegionAxisCount=1 -->
|
||||||
|
<!-- RegionCount=1 -->
|
||||||
|
<Region index="0">
|
||||||
|
<VarRegionAxis index="0">
|
||||||
|
<StartCoord value="0.0"/>
|
||||||
|
<PeakCoord value="0.38"/>
|
||||||
|
<EndCoord value="0.38"/>
|
||||||
|
</VarRegionAxis>
|
||||||
|
</Region>
|
||||||
|
</VarRegionList>
|
||||||
|
<!-- VarDataCount=1 -->
|
||||||
|
<VarData index="0">
|
||||||
|
<!-- ItemCount=1 -->
|
||||||
|
<NumShorts value="1"/>
|
||||||
|
<!-- VarRegionCount=1 -->
|
||||||
|
<VarRegionIndex index="0" value="0"/>
|
||||||
|
<Item index="0" value="[1638]"/>
|
||||||
|
</VarData>
|
||||||
|
</VarStore>
|
||||||
|
</avar>
|
||||||
|
|
||||||
|
</ttFont>
|
@ -227,6 +227,19 @@ class BuildTest(unittest.TestCase):
|
|||||||
expected_ttx_name=test_name,
|
expected_ttx_name=test_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_varlib_avar2(self):
|
||||||
|
"""Designspace file contains a 'weight' axis with <map> elements
|
||||||
|
modifying the normalization mapping as well as <mappings> element
|
||||||
|
modifying it post-normalization. An 'avar' table is generated.
|
||||||
|
"""
|
||||||
|
test_name = "BuildAvar2"
|
||||||
|
self._run_varlib_build_test(
|
||||||
|
designspace_name=test_name,
|
||||||
|
font_name="TestFamily3",
|
||||||
|
tables=["avar"],
|
||||||
|
expected_ttx_name=test_name,
|
||||||
|
)
|
||||||
|
|
||||||
def test_varlib_build_feature_variations(self):
|
def test_varlib_build_feature_variations(self):
|
||||||
"""Designspace file contains <rules> element, used to build
|
"""Designspace file contains <rules> element, used to build
|
||||||
GSUB FeatureVariations table.
|
GSUB FeatureVariations table.
|
||||||
@ -912,7 +925,6 @@ Expected: kern, mark.
|
|||||||
Got: kern.
|
Got: kern.
|
||||||
""",
|
""",
|
||||||
):
|
):
|
||||||
|
|
||||||
self._run_varlib_build_test(
|
self._run_varlib_build_test(
|
||||||
designspace_name="IncompatibleFeatures",
|
designspace_name="IncompatibleFeatures",
|
||||||
font_name="IncompatibleFeatures",
|
font_name="IncompatibleFeatures",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user