javalibgdxsizebitmap-fonts

How set Libgdx bitmap font size?


I'm rendering on screen the game fps using bitmap font but there are no methods for the size. This is a problem for me because my camera viewport size is very small so the text when rendered is huge and pixelated.

font.draw(batch, Float.toString(Gdx.graphics.getFramesPerSecond), x, y);

Solution

  • Did you try setScale() method? That's what I use to resize my font.

    myFont.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    myFont.setScale(scale);
    

    If you have trouble, leave a comment.

    Good Luck !!

    Edit :

    With the latest libgdx version, try to scale font like this :

    myFont.getData().setScale();