Jump to content
  • Advertisement


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


centering text

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

hey.. i was wondering how, if given a certain y coordinate on screen, you could center text along a given horizontal width. Say, for example, that this width is a 32pixel tile, and i want to center a label for it. How could I determine the starting x coordinate for drawing the text? Thanks!

Share this post

Link to post
Share on other sites
Hmm, I think I understand what you're asking. First you'll need to figure out where the center client coordinate is for the label you want to use.

Then use GetTextExtentExPoint() and it's siblings to figure out the width of the label. Divide by 2, subtract that number from the centered client coordinate from step one and draw there.


That's the list of the font functions.

[edited by - jonstelly on July 30, 2002 1:08:09 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!