Method Select
Select(FontFace, out int, out int, out int)
Selects the ascent, descent and line gap in font units, before any twip conversion.
public static void Select(FontFace face, out int ascent, out int descent, out int lineGap)
Parameters
faceFontFaceThe face to select for. Must not be null.
ascentintReceives the ascent above the baseline (positive fUnits).
descentintReceives the descent below the baseline (positive fUnits).
lineGapintReceives the additional leading (non-negative fUnits).
Remarks
When OS/2 fsSelection bit 7 (USE_TYPO_METRICS) is set the face asks to be laid
out on its typographic metrics and Word obliges, so those are used verbatim. Cambria
Math is the face that makes this matter: it declares win metrics of 6383/5045 over a
2048 unit em, which are a glyph-extent bound rather than a line height.
Otherwise the ascent and descent are the OS/2 Windows pair — measured, that is where
Word puts the baseline — and the line gap is whatever the hhea family adds
beyond that pair rather than hhea.lineGap itself. The distinction is
the whole rule and it is not cosmetic:
-
Calibri declares an
hhea.lineGapof 452/2048 em, but its Windows pair (1950 + 550) already equals its hhea sum (1536 + 512 + 452), so adding the gap outright would inflate every Calibri line by 22%. Consolas and Cambria behave the same way. - Times New Roman's Windows pair is the tight one (1825 + 443) and falls 87 units short of its hhea sum, which is exactly the leading Word adds and a Windows-only sum drops. Arial falls 67 units short the same way.
Taking the deficit rather than the raw gap also means the line box can only grow, never shrink: a face whose hhea sum is smaller than its Windows pair keeps the height it measures today, which is the conservative reading where no oracle exists.