GetTextMetrics function (wingdi.h)
The GetTextMetrics function fills the specified buffer with the metrics for the currently selected font.
Syntax
BOOL GetTextMetrics(
[in] HDC hdc,
[out] LPTEXTMETRIC lptm
);
Parameters
[in] hdc
A handle to the device context.
[out] lptm
A pointer to the TEXTMETRIC structure that receives the text metrics.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Remarks
To determine whether a font is a TrueType font, first select it into a DC, then call GetTextMetrics, and then check for TMPF_TRUETYPE in TEXTMETRIC.tmPitchAndFamily. Note that GetDC returns an uninitialized DC, which has "System" (a bitmap font) as the default font; thus the need to select a font into the DC.
Examples
For an example, see "Displaying Keyboard Input" in Using Keyboard Input or Drawing Text from Different Fonts on the Same Line.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | wingdi.h (include Windows.h) |
Library | Gdi32.lib |
DLL | Gdi32.dll |