[ttFont] Apply review comments
This commit is contained in:
parent
7a22c0fb07
commit
e5bf2a7f1a
@ -16,7 +16,6 @@ def _make_map(font, chars, gids):
|
|||||||
assert len(chars) == len(gids)
|
assert len(chars) == len(gids)
|
||||||
glyphNames = font.getGlyphNameMany(gids)
|
glyphNames = font.getGlyphNameMany(gids)
|
||||||
cmap = {}
|
cmap = {}
|
||||||
glyphOrder = font.getGlyphOrder()
|
|
||||||
for char,gid,name in zip(chars,gids,glyphNames):
|
for char,gid,name in zip(chars,gids,glyphNames):
|
||||||
if gid == 0:
|
if gid == 0:
|
||||||
continue
|
continue
|
||||||
|
@ -1209,7 +1209,7 @@ class STXHeader(BaseConverter):
|
|||||||
def _readLigatures(self, reader, font):
|
def _readLigatures(self, reader, font):
|
||||||
limit = len(reader.data)
|
limit = len(reader.data)
|
||||||
numLigatureGlyphs = (limit - reader.pos) // 2
|
numLigatureGlyphs = (limit - reader.pos) // 2
|
||||||
return font.getGlyphNameMany (reader.readUShortArray(numLigatureGlyphs))
|
return font.getGlyphNameMany(reader.readUShortArray(numLigatureGlyphs))
|
||||||
|
|
||||||
def _countPerGlyphLookups(self, table):
|
def _countPerGlyphLookups(self, table):
|
||||||
# Somewhat annoyingly, the morx table does not encode
|
# Somewhat annoyingly, the morx table does not encode
|
||||||
|
@ -920,15 +920,16 @@ class ClassDef(FormatSwitchingBaseTable):
|
|||||||
elif self.Format == 2:
|
elif self.Format == 2:
|
||||||
records = rawTable["ClassRangeRecord"]
|
records = rawTable["ClassRangeRecord"]
|
||||||
for rec in records:
|
for rec in records:
|
||||||
|
cls = rec.Class
|
||||||
|
if not cls:
|
||||||
|
continue
|
||||||
start = rec.Start
|
start = rec.Start
|
||||||
end = rec.End
|
end = rec.End
|
||||||
cls = rec.Class
|
|
||||||
startID = font.getGlyphID(start)
|
startID = font.getGlyphID(start)
|
||||||
endID = font.getGlyphID(end) + 1
|
endID = font.getGlyphID(end) + 1
|
||||||
glyphNames = font.getGlyphNameMany(range(startID, endID))
|
glyphNames = font.getGlyphNameMany(range(startID, endID))
|
||||||
if cls:
|
for glyphName in glyphNames:
|
||||||
for glyphName in glyphNames:
|
classDefs[glyphName] = cls
|
||||||
classDefs[glyphName] = cls
|
|
||||||
else:
|
else:
|
||||||
log.warning("Unknown ClassDef format: %s", self.Format)
|
log.warning("Unknown ClassDef format: %s", self.Format)
|
||||||
self.classDefs = classDefs
|
self.classDefs = classDefs
|
||||||
|
@ -569,6 +569,7 @@ class TTFont(object):
|
|||||||
glyphIDs = [d.get(glyphName) for glyphName in lst]
|
glyphIDs = [d.get(glyphName) for glyphName in lst]
|
||||||
|
|
||||||
if any(glyphID is None for glyphID in glyphIDs):
|
if any(glyphID is None for glyphID in glyphIDs):
|
||||||
|
# TODO Add something faster
|
||||||
getGlyphID = self.getGlyphID
|
getGlyphID = self.getGlyphID
|
||||||
return [getGlyphID(glyphName) for glyphName in lst]
|
return [getGlyphID(glyphName) for glyphName in lst]
|
||||||
|
|
||||||
@ -581,7 +582,6 @@ class TTFont(object):
|
|||||||
|
|
||||||
def _buildReverseGlyphOrderDict(self):
|
def _buildReverseGlyphOrderDict(self):
|
||||||
self._reverseGlyphOrderDict = d = {}
|
self._reverseGlyphOrderDict = d = {}
|
||||||
glyphOrder = self.getGlyphOrder()
|
|
||||||
for glyphID,glyphName in enumerate(self.getGlyphOrder()):
|
for glyphID,glyphName in enumerate(self.getGlyphOrder()):
|
||||||
d[glyphName] = glyphID
|
d[glyphName] = glyphID
|
||||||
return d
|
return d
|
||||||
|
Loading…
x
Reference in New Issue
Block a user