Archived

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

Centering text with wglUseFontBitmaps?

This topic is 6036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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