How to draw smooth text in libgdx?

JustOneMan picture JustOneMan · Feb 3, 2013 · Viewed 33.7k times · Source

I try to draw simple text in my android game on libgdx, but it's look sharp. How to make text look smooth in different resolutions? My Code:

private BitmapFont font;

font = new BitmapFont();

font.scale((ppuX*0.02f));

font.draw(spb, "Score:", width/2-ppuX*2f, height-0.5f*ppuY);

Answer

bluepuppy picture bluepuppy · Aug 5, 2013
font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

This gets the texture used in a BitmapFont and changes its filtering to bilinear, allowing higher resulting image quality while both up- and downscaling it at the cost of slightly slower (the difference is usually not noticeable) GPU rendering.