From doc :
targetWidth : The width used for alignment, line wrapping, and truncation. May be zero if those features are not used.
wrap : If true then (a word or unit of text) to be carried over to a new line automatically as the margin is reached, or to fit around embedded features.
If false, the text will only wrap where it contains newlines (\n).
EDIT
Test code : Practical demonstration, how targetWidth and wrap works in GlyphLayout
constructor.
public class MyGdxGame extends ApplicationAdapter {
private GlyphLayout glyphLayout[];
private BitmapFont bitmapFont;
private float targetWidth=250;
private ShapeRenderer shapeRenderer;
private SpriteBatch spriteBatch;
private float xPos[]={450,450,450,30,450,880};
private float yPos[]={550,480,410,340,340,340};
@Override
public void create () {
spriteBatch=new SpriteBatch();
shapeRenderer=new ShapeRenderer();
shapeRenderer.setAutoShapeType(true);
bitmapFont=new BitmapFont(Gdx.files.internal("skin/poet.fnt"));
glyphLayout=new GlyphLayout[6];
glyphLayout[0]=new GlyphLayout(bitmapFont, "LOADING SCREENsssssssssssssssssssssssssssssssssssss", Color.BLACK, targetWidth, Align.left, false);
glyphLayout[1]=new GlyphLayout(bitmapFont, "LOADING SCREENsssssssssssssssssssssssssssssssssssss", Color.BLACK, targetWidth, Align.right, false);
glyphLayout[2]=new GlyphLayout(bitmapFont, "LOADING SCREENsssssssssssssssssssssssssssssssssssss", Color.BLACK, targetWidth, Align.center, false);
glyphLayout[3]=new GlyphLayout(bitmapFont, "LOADING SCREENsssssssssssssssssssssssssssssssssssss", Color.BLACK, targetWidth, Align.left, true);
glyphLayout[4]=new GlyphLayout(bitmapFont, "LOADING SCREENsssssssssssssssssssssssssssssssssssss", Color.BLACK, targetWidth, Align.right, true);
glyphLayout[5]=new GlyphLayout(bitmapFont, "LOADING SCREENsssssssssssssssssssssssssssssssssssss", Color.BLACK, targetWidth, Align.center, true);
}
@Override
public void render() {
Gdx.gl.glClearColor(1f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
spriteBatch.begin();
for (int i=0;i<glyphLayout.length;i++) {
bitmapFont.draw(spriteBatch, glyphLayout[i], xPos[i], yPos[i]);
}
spriteBatch.end();
shapeRenderer.begin();
shapeRenderer.setColor(Color.BLUE);
shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
for (int i=0;i<glyphLayout.length;i++) {
shapeRenderer.rectLine(xPos[i], yPos[i], xPos[i] + targetWidth, yPos[i], 3f);
}
shapeRenderer.end();
}
@Override
public void dispose () {
bitmapFont.dispose();
shapeRenderer.dispose();
spriteBatch.dispose();
}
}
Output :
