Reputation: 289
I'm trying to draw simple text with libGDX on the screen. The thing that I want to consider is the size of the text. I would like to draw score of the player on the screen which i would like it to be big. But even i use the freetype fonts, it's not looking smooth. Here is the code:
SpriteBatch batch;
String string;
FreeTypeFontGenerator generator;
FreeTypeFontParameter parameter;
BitmapFont font;
@Override
public void create () {
batch = new SpriteBatch();
generator = new FreeTypeFontGenerator(Gdx.files.internal("arial.ttf"));
parameter = new FreeTypeFontParameter();
parameter.size = 100;
font = generator.generateFont(parameter);
string = "0123456";
}
@Override
public void render () {
Gdx.gl.glClearColor(0, 0, 0, 1);
batch.begin();
font.draw(batch, string, 50, 400);
batch.end();
}
Am i on the right path to draw the score or some HUD screen to the viewport? Is there a nicer way or is there a way to do this with the fonts easily? (For starting to learn from scratch?)
EDIT: Here is how it looks like
Upvotes: 1
Views: 677
Reputation: 460
Try setting the minFilter and magFilter of FreeTypeFontGeneratorParameter to Linear, like this:
@Override
public void create () {
batch = new SpriteBatch();
generator = new FreeTypeFontGenerator(Gdx.files.internal("arial.ttf"));
parameter = new FreeTypeFontParameter();
parameter.size = 100;
parameter.minFilter = Texture.TextureFilter.Linear;
parameter.magFilter = Texture.TextureFilter.Linear;
font = generator.generateFont(parameter);
string = "0123456";
}
Upvotes: 1