* @param text text to paint.
* @return
*/
public static TextureRenderer makeText(String text) {
// create texture for the text
TextureRenderer textRenderer = new TextureRenderer(1, 3, false);
Graphics2D g2d = textRenderer.createGraphics();
FontRenderContext frc = g2d.getFontRenderContext();
Font f = new Font("Arial", Font.BOLD, 18);
String s = new String(text);
TextLayout tl = new TextLayout(s, f, frc);
// get the necessary size for the text to be rendered
Rectangle2D bounds = tl.getBounds();
// add some margin...
int width = (int) bounds.getWidth() + 6;
int height = (int) bounds.getHeight() + 6;
// create a new texture renderer with the exact correct width and height.
textRenderer = new TextureRenderer(width, height, true);
textRenderer.setSmoothing(true);
g2d = textRenderer.createGraphics();
g2d.setColor(Color.white);
//coordinate are inversed: 0:0 is top-left.
tl.draw(g2d, 3, height - 3);
textRenderer.markDirty(0, 0, width, height);
return textRenderer;
}