Hi all, i have a quite strange requirement. I need to calculate the width of a String (fix length of 60 chars)with a given Font and Font size. I need this to calculate if all Strings match into one Table (fix size) on an HTML page. Has anyone of you ever did this, or has an idea how to solve it ? Thx [ October 07, 2003: Message edited by: Oliver Refle ]
The FontMetrics class has several methods to help you with this.
int getMaxAdvance() The advance width (in pixels) of the widest character in the font. int bytesWidth(byte, int, int) The advance width of the text represented by the specified array of bytes. The first integer argument specifies the starting offset of the data within the byte array. The second integer argument specifies the maximum number of bytes to check. int charWidth(int), int charWidth(char) The advance width of the specified character. int charsWidth(char, int, int) The advance width of the string represented by the specified character array. int stringWidth(String) The advance width of the specified string. int getWidths() The advance width of each of the first 256 characters in the font.