-
Bug
-
Resolution: Fixed
-
P3
-
6
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b74)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b74, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Home Edition
5.1.2600 Service Pack 2 Build 2600
A DESCRIPTION OF THE PROBLEM :
An ArrayIndexOutOfBoundsException is thrown when calculating the string width of a string containing a '~' character with the font Everson Mono Unicode. This font file is probably broken, but previous versions of the jdk handled this more gracefully.
If a user has this font or another that causes the same problem on her system, this problem can cause any swing application that tries to use this font to fail.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. install the Everson Mono Unicode font in the windows font directory
2. run the test program
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
On jdk 1.5.0_06
width: 1
gets printed to standard out
ACTUAL -
An ArrayIndexOutOfBoundsException gets thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4924
at sun.font.FileFontStrike.getGlyphImagePtr(FileFontStrike.java:253)
at sun.font.FileFontStrike.getGlyphAdvance(FileFontStrike.java:484)
at sun.font.FileFontStrike.getCodePointAdvance(FileFontStrike.java:504)
at sun.font.FontDesignMetrics.handleCharWidth(FontDesignMetrics.java:402)
at sun.font.FontDesignMetrics.getLatinCharWidth(FontDesignMetrics.java:411)
at sun.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:469)
at sun.swing.SwingUtilities2.stringWidth(SwingUtilities2.java:369)
at javax.swing.SwingUtilities.computeStringWidth(SwingUtilities.java:816)
at com.siyeh.FontTest.main(FontTest.java:19)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.SwingUtilities;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.FontMetrics;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
public class FontTest {
public static void main(String[] args) throws FontFormatException,
IOException {
final File fontFile = new File("c:\\windows\\fonts\\evermono.ttf");
final Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile);
final FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(font);
final int width = SwingUtilities.computeStringWidth(fontMetrics, "~");
System.out.println("width: " + width);
}
}
---------- END SOURCE ----------
Release Regression From : 5.0
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
java version "1.6.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b74)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b74, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Home Edition
5.1.2600 Service Pack 2 Build 2600
A DESCRIPTION OF THE PROBLEM :
An ArrayIndexOutOfBoundsException is thrown when calculating the string width of a string containing a '~' character with the font Everson Mono Unicode. This font file is probably broken, but previous versions of the jdk handled this more gracefully.
If a user has this font or another that causes the same problem on her system, this problem can cause any swing application that tries to use this font to fail.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. install the Everson Mono Unicode font in the windows font directory
2. run the test program
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
On jdk 1.5.0_06
width: 1
gets printed to standard out
ACTUAL -
An ArrayIndexOutOfBoundsException gets thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4924
at sun.font.FileFontStrike.getGlyphImagePtr(FileFontStrike.java:253)
at sun.font.FileFontStrike.getGlyphAdvance(FileFontStrike.java:484)
at sun.font.FileFontStrike.getCodePointAdvance(FileFontStrike.java:504)
at sun.font.FontDesignMetrics.handleCharWidth(FontDesignMetrics.java:402)
at sun.font.FontDesignMetrics.getLatinCharWidth(FontDesignMetrics.java:411)
at sun.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:469)
at sun.swing.SwingUtilities2.stringWidth(SwingUtilities2.java:369)
at javax.swing.SwingUtilities.computeStringWidth(SwingUtilities.java:816)
at com.siyeh.FontTest.main(FontTest.java:19)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.SwingUtilities;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.FontMetrics;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
public class FontTest {
public static void main(String[] args) throws FontFormatException,
IOException {
final File fontFile = new File("c:\\windows\\fonts\\evermono.ttf");
final Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile);
final FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(font);
final int width = SwingUtilities.computeStringWidth(fontMetrics, "~");
System.out.println("width: " + width);
}
}
---------- END SOURCE ----------
Release Regression From : 5.0
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.