0

I want to calculate the size my Font needs, so my text will be displayed fully in one line without clipping.

Example

|-100px---HERE'S MY TEXT---100px-|

I have the DPI and all there stuff. Testing isn't a way, I am using Libgdx and the text ist display with an Button (Scene2D ui).

Daahrien
  • 10,190
  • 6
  • 39
  • 71
Xyz3R
  • 1,075
  • 1
  • 9
  • 12

1 Answers1

1

Call BitmapFont.getBounds(). The TextBounds it returns will tell you what you need. You can try a medium font, the go up or down based on how big or small the bounds are. I use this method to help scale UI sizes from old Droid 1s up to the new HD displays.

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html

Jeremy Scoggins
  • 954
  • 8
  • 18