Archived

This topic is now archived and is closed to further replies.

tesanders

Centering text with wglUseFontBitmaps?

Recommended Posts

Anyone know of a straightforward way to center text with bitmapped fonts (wglUseFontBitmaps)? NeHe''s Tutorial 13 demonstrates the use of bitmapped fonts, but I can''t seem to figure out how to get the width of a string. Tutorials 14 and 15 generate outlined fonts, which you can center quite easily. However, it seems bad practice to generate an outlined font just to get the metrics for the equivalent bitmapped one. Anyone have more luck on this front? Thanks, Thomas

Share this post


Link to post
Share on other sites
// find out how big in pixels the string is
SIZE sz;
GetTextExtentPoint32(m_pDC->m_hDC,theString,strlen(theString),&sz);


This assumes that you have set the bitmapped font as the current (GDI) font for this window

Share this post


Link to post
Share on other sites