GetCharWidthA function

The GetCharWidth function retrieves the widths, in logical coordinates, of consecutive characters in a specified range from the current font.

Note  This function is provided only for compatibility with 16-bit versions of Windows. Applications should call the GetCharWidth32 function, which provides more accurate results.
 

Syntax

BOOL GetCharWidthA(
  HDC   hdc,
  UINT  iFirst,
  UINT  iLast,
  LPINT lpBuffer
);

Parameters

hdc

A handle to the device context.

iFirst

The first character in the group of consecutive characters.

iLast

The last character in the group of consecutive characters, which must not precede the specified first character.

lpBuffer

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

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Remarks

GetCharWidth cannot be used on TrueType fonts. To retrieve character widths for TrueType fonts, use GetCharABCWidths.

The range is inclusive; that is, the returned widths include the widths of the characters specified by the iFirstChar and iLastChar parameters.

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

Requirements

   
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

GetCharABCWidths

GetCharABCWidthsFloat

GetCharWidth32

GetCharWidthFloat