I am trying to draw text onto the screen but it always ends up being pixelated no matter what I try. A lot of people say that adding the Linear TextureFilter works or offer other solutions but they don't really work for me. This is what I have now (I'm also using a ttf font):
public BitmapFont generateFont(String path, double size)
{
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(path));
FreeTypeFontGenerator.FreeTypeFontParameter parameters = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameters.genMipMaps = true;
parameters.color = Color.BLACK;
parameters.size = (int) Math.ceil(size);
parameters.magFilter = TextureFilter.Linear;
parameters.minFilter = TextureFilter.Linear;
generator.scaleForPixelHeight((int) size);
return generator.generateFont(parameters);
}
I've also changed the parameter size to (int) Math.ceil(2 * Gdx.graphics.getWidth() / 9);
and while that makes things a little bit smoother, it's nowhere near as crisp as some other texts are.
I'm wondering what I need to do in order to get smooth text along with how I can maintain that smoothness in different text sizes across different resolutions (I'm only targeting desktop right now since I'm really just messing around with Libgdx). It just seems like there are several different ways of doing this but I just want to know what's the best way to go about doing this.
minFilter MipMapLinearNearest
andmagFilter Nearest
. \$\endgroup\$2 * Gdx.graphics.getWidth() / 9
it makes things a little bit smoother. However, I would like to be able to specify the size of the text and have it still be smooth regardless of size. \$\endgroup\$