The Horizontal Metrics Tableを見ると、最適化によってlongHorMetric
構造のリスト + int16
のリストで構成されている。longHorMetric
構造のリストの長さはhheaのnumberOfHMetrics
で定まる。
さて、GitHub - fonttools/fonttools: A library to manipulate font files from Python.ではバイナリのコンパイル時にどうしてるんだろうなぁとコードを読んでみるとちゃんとこの最適化処理をしていた。
fonttools/_h_m_t_x.py at master · fonttools/fonttools · GitHubの部分を見るとfont["hmtx"].metrics
を後ろから舐めてadvanceWidthが等しい間はlastIndexを小さくしていっている。でいけるとこまで縮めたらleftSideBearings[numGlyphs - numberOfHMetrics]
用にadditionalMetricsという容れ物にLSBを詰めていっている。
fonttools/_h_m_t_x.py at master · fonttools/fonttools · GitHubでfont["hhea"]. numberOfHMetrics
の更新をかけているので、hheaのコンパイル時には最適化された値が格納されることになる。
なるほどなー