Search code examples
javaandroidlibgdx

BitmapFont class does not have getBound(String) method


Previously I used getBound method for BitmapFont class in libgdx, but now, I am unable to use it.

I cannot find the changes in latest version.

Any help is appreciated. Thank you


Solution

  • After the API 1.5.6 we have a different way to get the String bound. try this

    GlyphLayout layout = new GlyphLayout();
    layout.setText(bitmapFont,"text");
    float width = layout.width;
    float height = layout.height;
    

    and it's not recommended to create new GlyphLayout on each frame, create once and use it.