Jump to content
  • Advertisement
Sign in to follow this  
chibitotoro0_0

OpenGL Text Width and Height

This topic is 4065 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

I'm currently working on a GUI system in OpenGL and im making windows. I was just wondering if there exists a function within opengl or written otherwise to determine the pixel size of a string being drawn to screen using a certain font. The reason I need this is so that I can properly center the title of a window at the top. Thanks for the help

Share this post


Link to post
Share on other sites
Advertisement
You need to ask your OS for this information (on Windows, GDI can provide it). Alternatively, you could ask a font rendering API like FreeType that is abstracting the OS.

Alternatively, if you're using icky bitmap fonts, you can calculate it rather easily based on the same kind of information you used to create the font.

Share this post


Link to post
Share on other sites
Of course you can get the height and weight.

I have made myself a function which can draw a string exactly centralized vertically and horizontally, to a given x and y position.

You have to use GLYPHMETRICSFLOAT,wglUseFontOutlinesW

gmfCellIncX for horizontal measurement
Max of gmfBlackBoxY values for vertical measurement...

check out...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!