我如何知道 TrueType 字体的实际字母大小?

How do I know the actual letter size of a TrueType font?

TrueType 字体 table 存储有关实际字符布局的信息。即,符号在监视器上显示的大小(以像素或点为单位)。

供参考:我正在使用 fontTools 库处理字体 tables。

字形的高度没有在任何地方指定(至少,水平布局没有)。可能,您正在寻找的是 sxHeight from the 'OS/2' table (the distance between the baseline and the approximate height of non-ascending lowercase letters). There's also sxCapHeight 字段(用于大写字母)。但是,这些字段是在 OS/2 table.

的第二个版本中定义的

要找出字形的高度,您可以简单地从最高点减去它的最低点(即字形高度 = yMax - yMin)。 yMax 和 yMin 存储在 Glyph Header 中 'glyf' table(对于 TrueType 轮廓)。

如果您需要字形的宽度,“hmtx' table contains an advance width for every glyph in a font, as well as left-side and right-side bearings. 'hhea”table 包含最大提前宽度值 (advanceWidthMax)。