Reputation: 187
I'm using a Freetype font to display text. But the font always looks: #1 Unreadable(throught decreasing the font size):
generator = new FreeTypeFontGenerator(Gdx.files.internal("Fonts/LDFComicSans.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 5;
font = generator.generateFont(parameter); // font size 12 pixels
font.setColor(Color.BLACK);
font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
generator.dispose();
generator = new FreeTypeFontGenerator(Gdx.files.internal("Fonts/LDFComicSans.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 30;
font = generator.generateFont(parameter); // font size 12 pixels
font.setColor(Color.BLACK);
font.getData().setScale(0.15F, 0.15F);
font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
generator.dispose();
These are the camera/viewport settings I use:
camera = new OrthographicCamera(1280, 720);
batch = new SpriteBatch();
viewport = new StretchViewport(100,100,camera);
viewport.apply();
I think it's because the viewport is too small but I really don't want to change it. Does anyone know how to fix this?
Upvotes: 1
Views: 1243
Reputation: 93591
Following your #2 version, call setUseIntegerPositions(false)
on the font. By default it rounds character positions to the nearest integer, which looks terrible with a tiny viewport. You may want to give it mip maps and use MipMapLinearLinear for the min filter to compensate for the characters not being aligned with screen pixels (to reduce blurriness).
Upvotes: 5