Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4413096

Chinese font glyphs do not render correctly from GlyphVector

XMLWordPrintable

    • 2d
    • hopper
    • x86
    • windows_98
    • Verified



      Name: yyT116575 Date: 02/07/2001


      java version "1.3.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
      Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)

      All kinds of chinese glyphs do not render correctly using Java 2D. The pieces
      that make up the glyphs seem correct, however their relative positions are all
      wrong. I'm guessing that this is a bug in the treatment of composite glyphs?

      Below is a small Java application that displays two characters that I've had
      trouble with on the screen using Java 2D.

      Note that the glyphs are incorrect at the Shape stage - as I've used another
      method to render Shapes that also revealed this problem.

      k@rl

      /* CUT HERE */

      import java.awt.*;
      import java.awt.font.*;
      import java.awt.event.*;
      import java.awt.geom.*;
      import java.io.*;
      import java.awt.image.*;

      /**
       *
       * @author karl
       * @version
       */
      public class Bug extends java.lang.Object {

        /** Creates new Main */
        public Bug() {
        }

        /**
        * @param args the command line arguments
        */
        public static void main (String argv[]) {
          Font font = new Font( "PMingliu", 0, 1 );
          //exploreFont( font );
          makeWindowWithShape( font );
        }
          
        private static void makeWindowWithShape( Font font ) {
          BufferedImage img = new BufferedImage( 200, 200,BufferedImage.TYPE_INT_RGB );
          Graphics2D g2d = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img);
          FontRenderContext frc = g2d.getFontRenderContext();
              
          char [] chars = new char[3];
          chars[0] = '\u4e10';
          chars[1] = '\u4e11';
          chars[2] = 'A';
              
          GlyphVector gv = font.createGlyphVector( frc, chars );
          Shape shape = gv.getOutline();
              
          g2d.translate( 10, 100 );
          g2d.scale( 40, 40 );
          g2d.fill( shape );
          Frame frame = new MyFrame( img );
          frame.setSize( img.getWidth(), img.getHeight() );
          frame.show();
              
        }
          
        static class MyFrame extends Frame {
          MyFrame( BufferedImage img ) {
            super( "orac.net.nz" );
            this.img = img;
                  
            addWindowListener( new WindowAdapter() {
              public void windowClosing( WindowEvent e ) {
                System.exit(0);
              }
            });
          }
              
          public void paint( Graphics g ) {
            g.drawImage( img, 0, 0, getWidth(), getHeight(), null );
          }
              
          private BufferedImage img;
        }
      }

      /* CUT HERE */
      (Review ID: 116485)
      ======================================================================

            sherman Xueming Shen
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: