FIX: FontMetrics.charWidth() Function Returns Incorrect Values for Some International Language Fonts

ID: Q244553


The information in this article applies to:
  • Microsoft virtual machine


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 this to be a bug in the Microsoft products listed at the beginning of this article.
This bug was corrected in Microsoft VM build 3188 and later.


MORE INFORMATION

Steps to Reproduce Behavior

  1. On a computer with a Microsoft VM version earlier than 3188 installed, create a file Test.java with the following code:


  2. 
    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 );
    	}
    } 
  3. In a Command window compile Test.java using the following command:


  4. 
    jvc Test.java 
  5. Run the generated Test.class file using the following command:


  6. 
    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 


REFERENCES

The latest Microsoft VM is available for download at the following Web site:

SDK Updates - Microsoft Technologies for Java
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/

http://support.microsoft.com/support/java/

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Venkat Sunkara, Microsoft Corporation

Additional query words:

Keywords : kbJavaVM kbGrpJava kbDSupport
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: November 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.