From dcd30873d938c39b6009cc9553f1c9cebb92ea11 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sat, 12 Oct 2024 17:56:53 +0300 Subject: [PATCH] [outlineCompiler] Always make space the gid2 Fixes https://github.com/googlefonts/ufo2ft/issues/880 --- Lib/ufo2ft/util.py | 3 +++ tests/outlineCompiler_test.py | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Lib/ufo2ft/util.py b/Lib/ufo2ft/util.py index 17d4eff1..cbbc4947 100644 --- a/Lib/ufo2ft/util.py +++ b/Lib/ufo2ft/util.py @@ -41,6 +41,9 @@ def makeOfficialGlyphOrder(font, glyphOrder=None): if ".notdef" in names: names.remove(".notdef") order.append(".notdef") + if "space" in names: + names.remove("space") + order.append("space") for name in glyphOrder: if name not in names: continue diff --git a/tests/outlineCompiler_test.py b/tests/outlineCompiler_test.py index 5755ce5d..db3c0d7f 100644 --- a/tests/outlineCompiler_test.py +++ b/tests/outlineCompiler_test.py @@ -737,16 +737,16 @@ def test_compile_tweaked_glyph_order(self, quadufo): def test_compile_strange_glyph_order(self, quadufo): """Move space and .notdef to end of glyph ids - ufo2ft always puts .notdef first. + ufo2ft always puts .notdef and space first. """ NEW_ORDER = ["b", "a", "c", "d", "space", ".notdef"] EXPECTED_ORDER = [ ".notdef", + "space", "b", "a", "c", "d", - "space", "e", "f", "g", @@ -924,11 +924,11 @@ def test_duplicate_glyph_names(self, testufo): result = compileTTF(testufo, useProductionNames=True).getGlyphOrder() - assert result[1] == "ab" - assert result[2] == "ab.1" - assert result[3] == "ab.2" - assert result[4] == "ab.3" - assert result[5] == "ab.4" + assert result[2] == "ab" + assert result[3] == "ab.1" + assert result[4] == "ab.2" + assert result[5] == "ab.3" + assert result[6] == "ab.4" def test_too_long_production_name(self, testufo): name = "_".join(("a",) * 16)