JDK-4372087 : Font renders incorrectly for wide characters
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: unknown
  • Submitted: 2000-09-19
  • Updated: 2000-09-19
  • Resolved: 2000-09-19
Related Reports
Duplicate :  
Duplicate :  
Description
SYSTEM INFORMATION:
Win32

The problem is when a wide character like "W" displays as the first character
in a line, "W" will not be displayed properly, left partial of the character
is missing. 

Following is the testcase which demonstrates the problem:
TEST CASE:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;


public class FontBugExample
{
    public static final Font DEF_FONT = new Font( "SanSerif", Font.PLAIN, 11
);

    public static void main(String [] args)
    {
        JFrame f = new JFrame();

        JTextField jt = new JTextField("Welcome");
        jt.setFont(DEF_FONT);

        f.getContentPane().add(new JLabel("Part of the W is being renderered
in the previous                			 Cell"),BorderLayout.NORTH);
        f.getContentPane().add(jt, BorderLayout.SOUTH);

        f.setSize(400,100);
        f.setVisible(true);

        f.addWindowListener( new WindowAdapter()
		{
			public void windowClosing( WindowEvent e )
			{
				System.exit(0);
			}
		} );
    }
} 


JUSTIFICATION:

We urgently need to ship a fix to this problem to get the issue resolved
with our customer.  Our primary system is a large enterprise financial system with a Web interface written in Java, using 1.2.2.04. It is an expensive top of the range system and our customers are _very_ demanding. 

I realise that this appears to be a cosmetic problem, but the customer
involved is digging their heels in and is demanding a fix. They refuse to
use another font (they are a Swedish company, so maybe the problem looks
worse in Swedish?).


Comments
SUGGESTED FIX Following is the suggested fix: under src/share/native/sun/awt/font/ *** GlyphVector.cpp.bak Thu Sep 7 17:38:36 2000 --- GlyphVector.cpp Fri Sep 8 15:36:45 2000 *************** *** 1,5 **** /* ! * @(#)GlyphVector.cpp 1.28 99/04/27 * * Copyright 1998, 1999 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. --- 1,5 ---- /* ! * %W% %E% * * Copyright 1998, 1999 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. *************** *** 462,467 **** --- 462,471 ---- if (!glyphRef.fImage && glyphRef.fWidth && glyphRef.fHeight) { fImageRefs[i].pixels = theStrike.getImage(fGlyphs[i]); } + jfloat fX = hsFixedToFloat(glyphRef.fTopLeft.fX); + if (i == 0 && fX < 0) + x -= fX; + if (loadPositions) { fPositions[i*2] = x + hsFixedToFloat(glyphRef.fTopLeft.fX); fPositions[i*2+1] = y + hsFixedToFloat(glyphRef.fTopLeft.fY);
11-06-2004