Allow converting 'glyphXXX' to glyphID
There was an inconsistency: when allowVID was False, we were allowing
gid->glyphXXX, but not the reverse. This was allowing some fonts to
be loaded, but then not to be written back. Fix that.
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index 72fbac9..bf55cb4 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -558,8 +558,15 @@
self._buildReverseGlyphOrderDict()
return self.getGlyphID(glyphName)
else:
- if requireReal or not self.allowVID:
+ if requireReal:
raise KeyError(glyphName)
+ elif not self.allowVID:
+ # Handle glyphXXX only
+ if glyphName[:5] == "glyph":
+ try:
+ return int(glyphName[5:])
+ except (NameError, ValueError):
+ raise KeyError(glyphName)
else:
# user intends virtual GID support
try: