Archived

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

EGD Eric

Is there an easy way to center text in Ortho?

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
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