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: 6626403
Votes 0
Synopsis getFontMetrics hangs Java
Category java:classes_2d
Reported Against
Release Fixed 7(b28), 6u10(b09) (Bug ID:2156500)
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs
Submit Date 06-NOV-2007
Description
FULL PRODUCT VERSION :
Java 1.6.0 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode

ADDITIONAL OS VERSION INFORMATION :
Windows XP
Windows Vista

A DESCRIPTION OF THE PROBLEM :
Our customer is Motorola and they have their own Motorola font.
When we call getFontMetrics on the Mortorola font, Java hangs.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I have the Motorola font.  Please email me for the font.
Run the test code with Motorola7.ttf in the Windows\Fonts directory.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Not a hang.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.Font;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

   public class fontbug {

     public static void main(String args[]) {
           GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
           String[] fonts = env.getAvailableFontFamilyNames();
           String thisFont;
           Font testFont;
           JPanel testPanel = new JPanel();
           for (int i = 0; i < fonts.length; i++) {
                thisFont = fonts[i];
  
                if (thisFont != null && !thisFont.equals(""))
                {
                    System.out.println("Font name = " + thisFont );
                    // Use a plain style and size 10, just to see if the font has a width or height.
                    testFont = new Font(thisFont, Font.PLAIN, 10);
                    if (testPanel.getFontMetrics(testFont).charWidth('n') != 0  && testPanel.getFontMetrics(testFont).getHeight() != 0 )
                    {
     
                    }
                }
            }
       
       }
    }
---------- END SOURCE ----------
Posted Date : 2007-11-06 13:49:51.0
Work Around
N/A
Evaluation
Font has only few defined glyphs and they all are "special".

Attempt to calculate global hints result in the infinite loop because heuristics are not applicable and number of glyph is too small (so iteration step is 0).

Proposed fix is to make sure increment is not zero.
Posted Date : 2007-11-27 17:50:40.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang