Answer the question
In order to leave comments, you need to log in
LibGDX. How to output text correctly?
I dug in the UI documentation, found one display of the Label text, but you can’t change the font in it, only Scale, but it doesn’t look very nice. Actually, how to display text in LibGDX correctly?
Answer the question
In order to leave comments, you need to log in
Taken from this site
BitmapFont font;
public static final String FONT_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789][_!$%#@|\\/?-+=()*&.;,{}\"´`'<>";
font = TrueTypeFontFactory.createBitmapFont(Gdx.files.internal("font.ttf"), FONT_CHARACTERS, 12.5f, 7.5f, 1.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
font.setColor(1f, 0f, 0f, 1f);
batch.begin();
font.draw(font, "This is some text", 10, 10);
batch.end();
createBitmapFont()
and its parameters, you can read in the libgdx documentation. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question