Click to See Complete Forum and Search --> : Finding size of certain character


GeorgeM
May 15th, 1999, 12:04 PM
How can I determine the pixel dimentions of a certain character of a certain font with Win32 API?

Jaeyeon Lee
May 18th, 1999, 01:12 AM
Check GetCharABCWidths function.

Jason Teagle
May 18th, 1999, 02:45 AM
If hFont is the font you want to check, and you have a window hMyWindow, then use:

--- char cString[] = "X";
HDC hDC ;
HFONT hFntOld ;
int iLength ;
SIZE sFontSize ;

hDC = GetDC(hMyWindow);
hFntOld = (HFONT)SelectObject(hDC, hFont);

iLength = strlen(cString);
GetTextExtentPoint32(hDC, cString, iLength, &sFontSize);

// Now, sFontSize.cx has the width and sFontSize.cy has the height
// of "X" in your font.

// Tidy up.
SelectObject(hDC, hFntOld);
ReleaseDC(hMyWindow, hDC);




---

Does this help?