GetKerningPairsA function (wingdi.h)

The GetKerningPairs function retrieves the character-kerning pairs for the currently selected font for the specified device context.


DWORD GetKerningPairsA(
  [in]  HDC           hdc,
  [in]  DWORD         nPairs,
  [out] LPKERNINGPAIR lpKernPair


[in] hdc

A handle to the device context.

[in] nPairs

The number of pairs in the lpkrnpair array. If the font has more than nNumPairs kerning pairs, the function returns an error.

[out] lpKernPair

A pointer to an array of KERNINGPAIR structures that receives the kerning pairs. The array must contain at least as many structures as specified by the nNumPairs parameter. If this parameter is NULL, the function returns the total number of kerning pairs for the font.

Return value

If the function succeeds, the return value is the number of kerning pairs returned.

If the function fails, the return value is zero.



The wingdi.h header defines GetKerningPairs as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


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

See also

Font and Text Functions

Fonts and Text Overview