From 0a1aa19c390bad00cd513961744e2724fc4509f5 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Mon, 15 Mar 2021 13:12:11 +0000 Subject: [PATCH] Test for better error message --- .../data/IncompatibleFeatures.designspace | 22 + .../IncompatibleFeatures-Bold.ttx | 578 ++++++++++++++++ .../IncompatibleFeatures-Regular.ttx | 626 ++++++++++++++++++ Tests/varLib/varLib_test.py | 27 +- 4 files changed, 1252 insertions(+), 1 deletion(-) create mode 100644 Tests/varLib/data/IncompatibleFeatures.designspace create mode 100644 Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Bold.ttx create mode 100644 Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Regular.ttx diff --git a/Tests/varLib/data/IncompatibleFeatures.designspace b/Tests/varLib/data/IncompatibleFeatures.designspace new file mode 100644 index 000000000..ab275164a --- /dev/null +++ b/Tests/varLib/data/IncompatibleFeatures.designspace @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Bold.ttx b/Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Bold.ttx new file mode 100644 index 000000000..a1803e9e9 --- /dev/null +++ b/Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Bold.ttx @@ -0,0 +1,578 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Simple Two Axis + + + Bold + + + 1.000;NONE;SimpleTwoAxis-Bold + + + Simple Two Axis Bold + + + Version 1.000 + + + SimpleTwoAxis-Bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Regular.ttx b/Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Regular.ttx new file mode 100644 index 000000000..7186a3e97 --- /dev/null +++ b/Tests/varLib/data/master_incompatible_features/IncompatibleFeatures-Regular.ttx @@ -0,0 +1,626 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Simple Two Axis + + + Regular + + + 1.000;NONE;SimpleTwoAxis-Regular + + + Simple Two Axis Regular + + + Version 1.000 + + + SimpleTwoAxis-Regular + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/varLib/varLib_test.py b/Tests/varLib/varLib_test.py index da1f94f4a..76d951def 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 +from fontTools.varLib.errors import VarLibValidationError, VarLibMergeError 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 @@ -813,7 +813,32 @@ class BuildTest(unittest.TestCase): assert ds_loaded.instances[0].location == {"weight": 0, "width": 50} + def test_varlib_build_incompatible_features(self): + try: + self._run_varlib_build_test( + designspace_name="IncompatibleFeatures", + font_name="IncompatibleFeatures", + tables=["GPOS"], + expected_ttx_name="IncompatibleFeatures", + save_before_dump=True, + ) + except VarLibMergeError as e: + assert str(e) == """ +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. +""" + except Exception: + self.fail('unexpected exception raised') + else: + self.fail('ExpectedException not raised') def test_load_masters_layerName_without_required_font(): ds = DesignSpaceDocument() s = SourceDescriptor()