Is there an easy way to center text in Ortho?

Started by
4 comments, last by EGD Eric 20 years, 1 month ago
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
Advertisement
pos_x = screenwidth / 2 - textwidth / 2
<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>
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''.
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.
[size="1"]
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.

This topic is closed to new replies.

Advertisement