* Gets the width of a String in text space units
* @param string the string that needs measuring
* @return the width of a String in text space units
*/
private float getStringWidth(String string){
DocumentFont font = gs.font;
char[] chars = string.toCharArray();
float totalWidth = 0;
for (int i = 0; i < chars.length; i++) {
float w = font.getWidth(chars[i]) / 1000.0f;
float wordSpacing = chars[i] == 32 ? gs.wordSpacing : 0f;
totalWidth += (w * gs.fontSize + gs.characterSpacing + wordSpacing) * gs.horizontalScaling;
}
return totalWidth;