-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0
-
generic
-
generic
Name: wl91122 Date: 07/26/99
<pre>
Although technically not a bug, this problem pertains to JDKs
1.1.5 and 1.2, probably all JDKs between and possibly others.
The source code for the java.awt.FontMetrics class does not
coorespond to the binary code. This means that the source
distributed with the JDK is not the source that was used to
build it.
Specifically, look at the src\java\awt\FontMetrics.java file
at the methods
public int stringWidth(String str)
public int charsWidth(char data[], int off, int len)
The segment of FontMetrics.java with these two methods is
as follows:
/**
* Returns the total advance width for showing the specified
* <code>String</code> in this <code>Font</code>. The advance width is
* the amount by which the current point is moved from one character
* to the next in a line of text.
* @param str the <code>String</code> to be measured
* @return the advance width of the specified <code>String</code>
* in the <code>Font</code> described by this
* <code>FontMetrics</code>.
* @see #bytesWidth(byte[], int, int)
* @see #charsWidth(char[], int, int)
*/
public int stringWidth(String str) {
int len = str.length();
char data[] = new char[len];
str.getChars(0, len, data, 0);
return charsWidth(data, 0, len);
}
/**
* Returns the total advance width for showing the specified array
* of characters in this <code>Font</code>. The advance width is the
* amount by which the current point is moved from one character to
* the next in a line of text.
* @param data the array of characters to be measured
* @param off the start offset of the characters in the array
* @param len the number of characters to be measured from the array
* @return the advance width of the subarray of the specified
* <code>char</code> array in the font described by
* this <code>FontMetrics</code> object.
* @see #charWidth(int)
* @see #charWidth(char)
* @see #bytesWidth(byte[], int, int)
* @see #stringWidth(String)
*/
public int charsWidth(char data[], int off, int len) {
return stringWidth(new String(data, off, len));
}
Notice that stringWidth unconditionally calls charsWidth and
that charsWidth unconditionally calls stringWidth. Can you
say infinite mutual recursion? Since both APIs work, the
binary code must not be implementing the above source.
It would be good to have the actual source of FontMetrics.
</pre>
(Review ID: 53783)
======================================================================
- relates to
-
JDK-4486745 java : win32 Java2 fontmetrics fix caused difference from 1.1.8 platform metrics
-
- Resolved
-