I was looking at the graphics class and there doesn't seem to be a means to get the width of a single text line, esp. if you change the size of the font.
g.setFont( new Font("Times New Roman" ); g.setFont( 36.f ); g.drawSingleLineText( "Hello TimesNewRoman", 30, 30 );
The problem i've found is that getStringWidth(" Hello TimesNewRoman") gets the width as tho the font is set to the initial size when loading in a new font, which I guess is 14. it doesn't take into account the setFont( 36.f ).
the workaround I found is:
float fontScale = newFontHeight / font.getHeight(); float actualStringWidth = font.getStringWidth(String) * fontScale;