From 07096d4af47b7b7aa2e34934d3182bac75560dbc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Feb 2023 14:02:08 -0700 Subject: [PATCH] Add test for compile/decompile toXML/fromXML of VarComposites --- Tests/ttLib/scaleUpem_test.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Tests/ttLib/scaleUpem_test.py b/Tests/ttLib/scaleUpem_test.py index a403cf1f2..7b4a706d3 100644 --- a/Tests/ttLib/scaleUpem_test.py +++ b/Tests/ttLib/scaleUpem_test.py @@ -2,6 +2,7 @@ from fontTools.ttLib import TTFont from fontTools.ttLib.scaleUpem import scale_upem import difflib import os +from io import BytesIO import shutil import sys import tempfile @@ -75,9 +76,24 @@ class ScaleUpemTest(unittest.TestCase): expected_ttx_path = self.get_path("varc-ac00-ac01-500upem.ttx") self.expect_ttx(font, expected_ttx_path, tables) - # While here just test that we can read the ttx + # While here, test a couple roundtrips + tables = [ + table_tag for table_tag in tables if table_tag not in {"maxp", "hhea"} + ] + xml = BytesIO() + font.saveXML(xml) + xml1 = BytesIO() + font.saveXML(xml1, tables=tables) + xml.seek(0) font = TTFont() - font.importXML(expected_ttx_path) + font.importXML(xml) + ttf = BytesIO() + font.save(ttf) + ttf.seek(0) + font = TTFont(ttf) + xml2 = BytesIO() + font.saveXML(xml2, tables=tables) + assert xml1.getvalue() == xml2.getvalue() # Scale our other varComposite font as well; without checking the expected font = TTFont(self.get_path("varc-6868.ttf"))