[glyf] Add tests for getGlyphID()

This commit is contained in:
Behdad Esfahbod 2023-10-16 13:14:01 -04:00
parent db393f6560
commit 27932c525b

View File

@ -400,6 +400,25 @@ class GlyfTableTest(unittest.TestCase):
[(0, 0), (100, 0), (0, 0), (0, -1000)], [(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: class GlyphTest:
def test_getCoordinates(self): def test_getCoordinates(self):