From d77c8901c8055b579d6cb0747551a8490100146a Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 10 Mar 2023 11:37:07 +0000 Subject: [PATCH] ttFont_test: add test for getGlyphID --- Tests/ttLib/ttFont_test.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/ttLib/ttFont_test.py b/Tests/ttLib/ttFont_test.py index 38f2bc373..962196fa9 100644 --- a/Tests/ttLib/ttFont_test.py +++ b/Tests/ttLib/ttFont_test.py @@ -262,3 +262,13 @@ def test_font_normalizeLocation_no_VF(): ttf = TTFont() with pytest.raises(TTLibError, match="Not a variable font"): ttf.normalizeLocation({}) + + +def test_getGlyphID(): + font = TTFont() + font.importXML(os.path.join(DATA_DIR, "TestTTF-Regular.ttx")) + + assert font.getGlyphID("space") == 3 + assert font.getGlyphID("glyph12345") == 12345 # virtual glyph + with pytest.raises(KeyError): + font.getGlyphID("non_existent")