• ### Announcements

#### Archived

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

# 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 on other sites
pos_x = screenwidth / 2 - textwidth / 2

##### Share on other sites
<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 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 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 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.

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627674
• Total Posts
2978558

• 11
• 11
• 10
• 12
• 22