I am trying to write a big text using BitmapFont in libGDX . But it shows on one line and the user can see only the first part of the text . How can I make that bitmapFont made new line automatically and show whole text on the screen ?

  • \$\begingroup\$ So basically you are looking for a "Word wrap" option. \$\endgroup\$
    – Kromster
    Aug 22, 2014 at 8:10
  • \$\begingroup\$ yes, something like that \$\endgroup\$ Aug 22, 2014 at 8:13

2 Answers 2


You should use BitmapFont.drawWrapped.

public BitmapFont.TextBounds drawWrapped(Batch batch,
                                     java.lang.CharSequence str,
                                     float x,
                                     float y,
                                     float wrapWidth)

All you need to do is set the wrapWidth variable as the maximum length of the line. In your case, this works better than BitmapFont.drawMultiLine because it automatically wraps rather than solely responding to \n.


Write multiline text in LibGdx

To write a multiline text with bitmapFont just use this following code-

String completeText= "In this text there are multi lines\n.To write this race in your game 
                     \n you have to write in proper manner.
                     \nYou have to make the text look better .";

             x,y,width,heigth, HAlignment.LEFT);

Isn't is simple to write a multiline text.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .