HDC hsurfacedc;
TEXTMETRIC tm;
if (!g_DirectXEngine.GetDirectDraw())
return (0);
LPDIRECTDRAWSURFACE lpddsworking = g_DirectXEngine.GetWorkingSurface();
if (!lpddsworking)
return (0);
lpddsworking->GetDC(&hsurfacedc);
if (!hsurfacedc) {
g_ErrorLog.ProcessError(NULL, "CMetaform::UpdateCharHeightAndWidth: Error using lpddsworking->GetDC", 0);
return (0);
}
HFONT hfont = CreateFontIndirect(&font);
SelectObject(hsurfacedc, hfont);
SetMapMode(hsurfacedc, MM_TEXT);
GetTextMetrics(hsurfacedc, &tm);
lpddsworking->ReleaseDC(hsurfacedc);
DeleteObject(hfont);
char_height = (MulDiv(tm.tmHeight, 96, g_DirectXEngine.GetLOGPIXELSY()));
char_width = (MulDiv(tm.tmAveCharWidth, 128, g_DirectXEngine.GetLOGPIXELSX()));
char buf[128];
sprintf(buf, "UPDATE: height: %d, width: %d", char_height, char_width);
g_Console.Message(buf);
return (1);
What am I doing wrong?
"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
How do you calculate the size a character will take up when drawn?
Using, the GDI, how do you find out the height and the width of the character in pixels?? So far I have:
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement