From e726217ae0d32a77748bdd79eff89ef71afc0264 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 10 Mar 2022 17:43:02 +0000 Subject: [PATCH] ttFont_test: add test for setGlyphOrder updating glyf.glyphOrder --- Tests/ttLib/ttFont_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/ttLib/ttFont_test.py b/Tests/ttLib/ttFont_test.py index 5e40e2658..d40832728 100644 --- a/Tests/ttLib/ttFont_test.py +++ b/Tests/ttLib/ttFont_test.py @@ -1,6 +1,7 @@ import io import os import re +import random from fontTools.ttLib import TTFont, newTable, registerCustomTableClass, unregisterCustomTableClass from fontTools.ttLib.tables.DefaultTable import DefaultTable @@ -118,3 +119,21 @@ def test_virtualGlyphId(): font.saveXML(out) outxml = normalize_TTX(out.getvalue()).splitlines() assert xml == outxml + + +def test_setGlyphOrder_also_updates_glyf_glyphOrder(): + # https://github.com/fonttools/fonttools/issues/2060#issuecomment-1063932428 + font = TTFont() + font.importXML(os.path.join(DATA_DIR, "TestTTF-Regular.ttx")) + current_order = font.getGlyphOrder() + + assert current_order == font["glyf"].glyphOrder + + new_order = list(current_order) + while new_order == current_order: + random.shuffle(new_order) + + font.setGlyphOrder(new_order) + + assert font.getGlyphOrder() == new_order + assert font["glyf"].glyphOrder == new_order