Does anyone know what is the formula to calculate height of bitmap font with specific size? I know that when I draw a string on a screen I'm creating a rectangle to do that and I want to know what is the height of this rectangle.
If you're using LibGDX version >= 1.5.6 then you can get height of font by GlyphLayout.
Bitmap font = new BitmapFont();
GlyphLayout layout = new GlyphLayout();
layout.setText(font, "meow");
float height = layout.height; //height of "meow"
but if still you're using LibGDX API < 1.5.6, you can get height by this
float height = font.getBounds("meow").height;
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