2
votes

I'm making a game using libgdx and box2d so my Orthographic Camera Viewport is only 20x12 pixels/meters, when I try to render the a font on screen it becomes really big and pixelated, I also tried to use hiera bitmapfont generator to fix the size problem but is still so pixelated that makes it impossible to read. Then I tried using FreetypeFont which allows to have better control of the font using FreetypeFont parameter and I'm also using two Orthographic camera now one for box2d and one for textures, how can I scale the libgdx camera? my box2d camera is 13x21 and It's 1 pixel = 1 meter.

 generator = new FreeTypeFontGenerator(Gdx.files.internal("Fonts/font.ttf"));
        parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
        parameter.size = 16;
        parameter.color = Color.BLACK;
        font = generator.generateFont(parameter);
1
Perhaps using a different camera for the fonts (like using a stage with labels) would solve this issue?p.streef

1 Answers

0
votes

Use a Camera with the screen resolution size, or your viewport resolution(in pixels) and translate your text coordinates to that camera, then render on this second camera the text and it will be perfectly readable. Be carefull with scales,

And remove the filters of the bitmafont with

myAwesomeBitmapFont.getRegion().getTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);