GetCharWidthI function (wingdi.h)

The GetCharWidthI function retrieves the widths, in logical coordinates, of consecutive glyph indices in a specified range from the current font.


BOOL GetCharWidthI(
  [in]  HDC    hdc,
  [in]  UINT   giFirst,
  [in]  UINT   cgi,
  [in]  LPWORD pgi,
  [out] LPINT  piWidths


[in] hdc

A handle to the device context.

[in] giFirst

The first glyph index in the group of consecutive glyph indices.

[in] cgi

The number of glyph indices.

[in] pgi

A pointer to an array of glyph indices. If this parameter is not NULL, it is used instead of the giFirst parameter.

[out] piWidths

A pointer to a buffer that receives the widths, in logical coordinates.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.


The GetCharWidthI function processes a consecutive glyph indices if the pgi parameter is NULL with the giFirst parameter indicating the first glyph index to process and the cgi parameter indicating how many glyph indices to process. Otherwise the GetCharWidthI function processes the array of glyph indices pointed to by the pgi parameter with the cgi parameter indicating how many glyph indices to process.

If a character does not exist in the current font, it is assigned the width of the default character.


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