From 9988054f3cc8b1d1e7f1155583c12a65978d2f32 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 20 Aug 2021 09:53:15 -0600 Subject: [PATCH] [ttFont] Remove requireReal To my knowledge this is not used by anyone. See https://github.com/fonttools/fonttools/issues/2334#issuecomment-902789001 --- Lib/fontTools/misc/testTools.py | 2 +- Lib/fontTools/ttLib/ttFont.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Lib/fontTools/misc/testTools.py b/Lib/fontTools/misc/testTools.py index e13a3c4e6..0978ed040 100644 --- a/Lib/fontTools/misc/testTools.py +++ b/Lib/fontTools/misc/testTools.py @@ -136,7 +136,7 @@ class MockFont(object): self._reverseGlyphOrder = AllocatingDict({'.notdef': 0}) self.lazy = False - def getGlyphID(self, glyph, requireReal=None): + def getGlyphID(self, glyph): gid = self._reverseGlyphOrder[glyph] return gid diff --git a/Lib/fontTools/ttLib/ttFont.py b/Lib/fontTools/ttLib/ttFont.py index fc0f97122..6b1435ab7 100644 --- a/Lib/fontTools/ttLib/ttFont.py +++ b/Lib/fontTools/ttLib/ttFont.py @@ -544,11 +544,11 @@ class TTFont(object): from fontTools.misc import textTools return textTools.caselessSort(self.getGlyphOrder()) - def getGlyphName(self, glyphID, requireReal=False): + def getGlyphName(self, glyphID): try: return self.getGlyphOrder()[glyphID] except IndexError: - if requireReal or not self.allowVID: + if not self.allowVID: # XXX The ??.W8.otf font that ships with OSX uses higher glyphIDs in # the cmap table than there are glyphs. I don't think it's legal... return "glyph%.5d" % glyphID @@ -563,7 +563,7 @@ class TTFont(object): self.VIDDict[glyphID] = glyphName return glyphName - def getGlyphID(self, glyphName, requireReal=False): + def getGlyphID(self, glyphName): if not hasattr(self, "_reverseGlyphOrderDict"): self._buildReverseGlyphOrderDict() glyphOrder = self.getGlyphOrder() @@ -573,9 +573,7 @@ class TTFont(object): self._buildReverseGlyphOrderDict() return self.getGlyphID(glyphName) else: - if requireReal: - raise KeyError(glyphName) - elif not self.allowVID: + if not self.allowVID: # Handle glyphXXX only if glyphName[:5] == "glyph": try: