When drawing text with "\n" characters in, text draws correctly with more than one line.
However, when getting the width of the text,
the code only gets the width of the topmost line in the text.What this means:If you have a String like this: "Hello\nMy name is Paul", the code will return the width of "hello", meaning your width value will be wrong.
Work Around:Code:
String text = ...;
String[] parts = text.split("\n");
int width = 0;
for(int dofor = 0; dofor < parts.length; dofor++){
width = Math.max(UnicodeFont.getWidth(parts[dofor], width);
}
Replace "..." with your text!