Jump to content
  • Advertisement

Archived

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

EGD Eric

Is there an easy way to center text in Ortho?

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

Like, to have text centered exactly. Like this:
            New Game
         Continue Game
            Credits
              Quit

not like this:
          New Game
          Continue Game
          Credits
          Quit

that just won''t cut it

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
pos_x = screenwidth / 2 - textwidth / 2

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
<pedantry>
Correct, although

pos_x = (screen_width - text_width) * 0.5

could well run faster - replacement of two divisions by a multiplication, though this will depend on how good at optimising your compiler is!

I''m pretty sure it''s also slightly (not that you could see it!) more accurate.
</pedantry>

Share this post


Link to post
Share on other sites
But how do I find the text width in pixels eh? It differs depending on the font size, the individual characters. ''A'' is wider than ''l''.

Share this post


Link to post
Share on other sites
depends what kind of fonts you''re using... If it''s bitmap fonts (i bet it is) your font code will have it somewhere. In fact no matter how it''s done, your font lib will know about it. UTSL.

Share this post


Link to post
Share on other sites
What does UTSL stand for? Yes, it is bitmap fonts, but I can use outline fonts if there''s an easier way to do it with them.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!