From 27932c525bf9837b3a838316f3ad6cad1a21a038 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 16 Oct 2023 13:14:01 -0400 Subject: [PATCH] [glyf] Add tests for getGlyphID() --- Tests/ttLib/tables/_g_l_y_f_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/ttLib/tables/_g_l_y_f_test.py b/Tests/ttLib/tables/_g_l_y_f_test.py index ff160a4da..ce2e0e575 100644 --- a/Tests/ttLib/tables/_g_l_y_f_test.py +++ b/Tests/ttLib/tables/_g_l_y_f_test.py @@ -400,6 +400,25 @@ class GlyfTableTest(unittest.TestCase): [(0, 0), (100, 0), (0, 0), (0, -1000)], ) + def test_getGlyphID(self): + # https://github.com/fonttools/fonttools/pull/3301#discussion_r1360405861 + glyf = newTable("glyf") + glyf.setGlyphOrder([".notdef", "a", "b"]) + glyf.glyphs = {} + for glyphName in glyf.glyphOrder: + glyf[glyphName] = Glyph() + + assert glyf.getGlyphID("a") == 1 + + with pytest.raises(ValueError): + glyf.getGlyphID("c") + + glyf["c"] = Glyph() + assert glyf.getGlyphID("c") == 3 + + del glyf["b"] + assert glyf.getGlyphID("c") == 2 + class GlyphTest: def test_getCoordinates(self):