Skip to main content
Use code formatting and link markup
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

I think you want full controllcontrol of the text box, right?

Here is copiedsome code for you:

GlyphLayout layout = new GlyphLayout(); //dont do this every frame! Store it as member layout.setText("meow"); float width = layout.width;// contains the width of the current set text float height = layout.height; // contains the height of the current set text

Code it taken from:, https://stackoverflow.com/questions/16600547/how-get-a-string-width-in-libgdxsoured from another Q&A thread:

GlyphLayout layout = new GlyphLayout(); //dont do this every frame! Store it as member
layout.setText("meow");
float width = layout.width;// contains the width of the current set text
float height = layout.height; // contains the height of the current set text

I think you want full controll of the text box, right?

Here is copied code for you:

GlyphLayout layout = new GlyphLayout(); //dont do this every frame! Store it as member layout.setText("meow"); float width = layout.width;// contains the width of the current set text float height = layout.height; // contains the height of the current set text

Code it taken from: https://stackoverflow.com/questions/16600547/how-get-a-string-width-in-libgdx

I think you want full control of the text box, right?

Here is some code for you, soured from another Q&A thread:

GlyphLayout layout = new GlyphLayout(); //dont do this every frame! Store it as member
layout.setText("meow");
float width = layout.width;// contains the width of the current set text
float height = layout.height; // contains the height of the current set text
Source Link

I think you want full controll of the text box, right?

Here is copied code for you:

GlyphLayout layout = new GlyphLayout(); //dont do this every frame! Store it as member layout.setText("meow"); float width = layout.width;// contains the width of the current set text float height = layout.height; // contains the height of the current set text

Code it taken from: https://stackoverflow.com/questions/16600547/how-get-a-string-width-in-libgdx