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);
Did you try setScale() method that 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();
I often use what minos23 suggested. But the downfall is that it can look pixelated especially when scaling upwards. A fancy large bitmap font can take up a lot of space and if you need many different fonts you might go over your budget.
By using Gdx.Freetype you are able to create bitmapfonts at runtime from small .ttf
files. This means you only need to ship the .ttf
files with your app and can generate a font based on user settings like resolution.
Other then scaling and the freetype solution is having multiple bitmaps of different font sizes. This way your fonts stay crisp all time but at the cost of runtime performance to generate the proper fonts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With