Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6720240
Votes 0
Synopsis IOB exception when getting font metrics of hershey font
Category java:classes_2d
Reported Against
Release Fixed 7(b33), 6-open(b12) (Bug ID:2164891)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6609143
Submit Date 27-JUN-2008
Description
The following code throws exception with hershey font that can be found in recent 
fedora release:
            
  Font f = Font.createFont(Font.TYPE1_FONT, new File("hrger.pfa"));
  FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(f);
  fm.getWidths(); //Index out of bounds is thrown here.

Exception stack trace:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at sun.font.FileFontStrike.setCachedGlyphPtr(FileFontStrike.java:374)
        at sun.font.FileFontStrike.setCachedGlyphPtr(FileFontStrike.java:425)
        at sun.font.FileFontStrike.getGlyphImagePtr(FileFontStrike.java:284)
        at sun.font.FileFontStrike.getGlyphAdvance(FileFontStrike.java:496)
        at sun.font.FileFontStrike.getCodePointAdvance(FileFontStrike.java:526)
        at sun.font.FontDesignMetrics.handleCharWidth(FontDesignMetrics.java:415)
        at sun.font.FontDesignMetrics.getWidths(FontDesignMetrics.java:537)
        at HersheyFont.main(HersheyFont.java:27)


Test source code and font file are attached to this CR.

This can be reproduced on openjdk 6 "build 1.6.0-ea-b10" on at least 
solaris x86 and linux.
 

on jdk 7 the test code above runs successfully on both solaris and linux.
Posted Date : 2008-06-27 16:04:08.0
Work Around
N/A
Evaluation
Reassigned to Java2D team.
Posted Date : 2008-06-30 09:14:34.0

I *suspect* that reason for exceptions and solution are covered by 6609143.
(need to update NullFontScaler to return 1 as number of glyphs).

However, i can not reproduce this problem with your testcase on my windows using jdk7 (build both with freetype and t2k) and this problem is NOT fixed there. 

It is possible that only freetype is failing on this font and t2k works with it.
But still, it should not be platform dependent and should fail on other platforms 
using same font for both 6-open and 7. Ned further investigation.
Posted Date : 2008-06-30 12:44:24.0

Problem is reproducible with freetype version of build only. T2K works just fine.

Further analysis shown that simple freetype program that only initializes freetype library
and tries to create font face for thhis font file fails with error code 3.
This means "invalid file format" according to fterrdef.h

I.e. the reason why font is considered to be malformed is inside freetype (and may be even resolved in the newer version of library or perhaps this is build issue).
It is NOT inside JDK codebase and we can not fix it to accept this font.

However, we still need to fix NullScaler used as substitute for bad fonts to report it contains 1 glyph (missing glyph) to avoid ArrayIndexOutOfBoundException.
(and this needs to be fixed in both JDK 7 and 6-open)
Posted Date : 2008-07-10 16:50:24.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang