diff options
Diffstat (limited to 'Tests/varLib/varLib_test.py')
-rw-r--r-- | Tests/varLib/varLib_test.py | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/Tests/varLib/varLib_test.py b/Tests/varLib/varLib_test.py index da1f94f4..b8e7183b 100644 --- a/Tests/varLib/varLib_test.py +++ b/Tests/varLib/varLib_test.py @@ -1,7 +1,7 @@ -from fontTools.misc.py23 import * from fontTools.ttLib import TTFont, newTable from fontTools.varLib import build, load_designspace from fontTools.varLib.errors import VarLibValidationError +import fontTools.varLib.errors as varLibErrors from fontTools.varLib.mutator import instantiateVariableFont from fontTools.varLib import main as varLib_main, load_masters from fontTools.varLib import set_default_weight_width_slant @@ -10,6 +10,7 @@ from fontTools.designspaceLib import ( ) from fontTools.feaLib.builder import addOpenTypeFeaturesFromString import difflib +from io import BytesIO import os import shutil import sys @@ -813,6 +814,62 @@ class BuildTest(unittest.TestCase): assert ds_loaded.instances[0].location == {"weight": 0, "width": 50} + def test_varlib_build_incompatible_features(self): + with pytest.raises( + varLibErrors.ShouldBeConstant, + match = """ + +Couldn't merge the fonts, because some values were different, but should have +been the same. This happened while performing the following operation: +GPOS.table.FeatureList.FeatureCount + +The problem is likely to be in Simple Two Axis Bold: + +Incompatible features between masters. +Expected: kern, mark. +Got: kern. +"""): + + self._run_varlib_build_test( + designspace_name="IncompatibleFeatures", + font_name="IncompatibleFeatures", + tables=["GPOS"], + expected_ttx_name="IncompatibleFeatures", + save_before_dump=True, + ) + + def test_varlib_build_incompatible_lookup_types(self): + with pytest.raises( + varLibErrors.MismatchedTypes, + match = r"MarkBasePos, instead saw PairPos" + ): + self._run_varlib_build_test( + designspace_name="IncompatibleLookupTypes", + font_name="IncompatibleLookupTypes", + tables=["GPOS"], + expected_ttx_name="IncompatibleLookupTypes", + save_before_dump=True, + ) + + def test_varlib_build_incompatible_arrays(self): + with pytest.raises( + varLibErrors.ShouldBeConstant, + match = """ + +Couldn't merge the fonts, because some values were different, but should have +been the same. This happened while performing the following operation: +GPOS.table.ScriptList.ScriptCount + +The problem is likely to be in Simple Two Axis Bold: +Expected to see .ScriptCount==1, instead saw 0""" + ): + self._run_varlib_build_test( + designspace_name="IncompatibleArrays", + font_name="IncompatibleArrays", + tables=["GPOS"], + expected_ttx_name="IncompatibleArrays", + save_before_dump=True, + ) def test_load_masters_layerName_without_required_font(): ds = DesignSpaceDocument() |