Micro-optimize hmtx/vmtx loading
diff --git a/Lib/fontTools/ttLib/tables/_h_m_t_x.py b/Lib/fontTools/ttLib/tables/_h_m_t_x.py
index acb686b..09569ef 100644
--- a/Lib/fontTools/ttLib/tables/_h_m_t_x.py
+++ b/Lib/fontTools/ttLib/tables/_h_m_t_x.py
@@ -33,12 +33,13 @@
if data:
warnings.warn("too much 'hmtx'/'vmtx' table data")
self.metrics = {}
+ glyphOrder = ttFont.getGlyphOrder()
for i in range(numberOfMetrics):
- glyphName = ttFont.getGlyphName(i)
+ glyphName = glyphOrder[i]
self.metrics[glyphName] = list(metrics[i*2:i*2+2])
lastAdvance = metrics[-2]
for i in range(numberOfSideBearings):
- glyphName = ttFont.getGlyphName(i + numberOfMetrics)
+ glyphName = glyphOrder[i + numberOfMetrics]
self.metrics[glyphName] = [lastAdvance, sideBearings[i]]
def compile(self, ttFont):