Libgdx font blurring

Solved, kind of:
I read a description of the font, which included: [quote]Designed to be used at 10px and multiples thereof
[/quote]
So, I’m changing my game to work with this.

I use the following code to generate a font and for some reason it is not clear.


FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
FreeTypeFontParameter params = new FreeTypeFontParameter();
params.minFilter = TextureFilter.Nearest;
params.magFilter = TextureFilter.Nearest;
textFont = gen.generateFont(params);
params.size = 16;

BitmapFont font = gen.generateFont(params);

gen.dispose();

Should I be using a different min/mag filter or is it the font file that is causing the blur?
The font is called Munro.

Here’s an image of the font in use: http://i.imgur.com/chQyQaK.png

Thanks a bunch.

I use


TextureFilter.Linear, TextureFilter.Linear

and my fonts look nice.

Hmm have you tried not using any sort of filter?

I don’t use any filters and all my fonts turn out just fine, without any blur. Even with a wide range of different sizes.

There is always a filter, they’re not optional. :stuck_out_tongue:
(Unless scaling is simply disallowed)

Sorry let me rephrase. I don’t set the filter, I just leave it being whatever default is.

FreeTypeFonts can be any size, they don’t have to be 10px or multiples of it. The comment you posted might be regarding the use of the default BitmapFont provided by LibGDX in their uiskin…which doesn’t apply to what you’re doing.

It appears you’re generating two fonts, “textFont” and “font”. Are you trying to create two different fonts with two different sizes or just one font? (As a side note, the default font size for the parameter is 16, so you are actually generating two fonts of size 16.)

Are you resizing the font(s) elsewhere? With FreeTypeFonts you don’t want to resize these later, you can create the font at the specific size that you need and it will look perfect.

You also want to make sure that you set all the parameters BEFORE you generate the BitmapFont. Generating the font is the last step because it creates an actual bitmap image of all the characters in your font using whatever parameters you have set at the time. As long as you get the size right and don’t try to change it later, the font should come out perfect (and the filter types don’t matter as these only apply when scaling).

FreeTypeFontGenerator gen = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
FreeTypeFontParameter params = new FreeTypeFontParameter();
params.size = 16;
BitmapFont font = gen.generateFont(params);
gen.dispose();