Microsoft KB Archive/244553

= FIX: FontMetrics.charWidth function returns incorrect values for some international language fonts =

Article ID: 244553

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Java Virtual Machine

-



This article was previously published under Q244553



SYMPTOMS
Using the FontMetrics.charWidth method to get the width of a character might return zero or an incorrect value when using the GulimChe font (a Korean language font).



RESOLUTION
To resolve this problem, update your version of the Microsoft virtual machine (Microsoft VM) for Java to build 3188 or later. See "References" section for links to download the latest Microsoft VM.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Microsoft VM build 3188 and later.



Steps to Reproduce Behavior
  On a computer with a Microsoft VM version earlier than 3188 installed, create a file Test.java with the following code: import java.awt.*; import java.awt.event.*;

import com.ms.awt.FontX;

public class Test {   static public final void main( String[] args ) {       Test t = new Test; }

public Test {       FontX f = new FontX( "GulimChe", Font.PLAIN, 11 ); FontMetrics fm = Toolkit.getDefaultToolkit.getFontMetrics( f );

System.out.println("Font: " + f.getFamily); System.out.println( "Width of the character "+'A'+" is "+fm.charWidth( 'A') ); System.out.println( "Width of the String "+"A"+" is "+fm.stringWidth( "A" ) );

System.exit( 0 ); } }                     In a Command window compile Test.java using the following command: jvc Test.java   Run the generated Test.class file using the following command: jview Test.class You should see the following output:

C:\>jview Test.class Font: GulimChe Width of the character A is 0 Width of the String A is 6



