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

Transform T.Chinese Font produce incorrect shape

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.1
    • 1.4.0
    • client-libs
    • 2d
    • hopper
    • x86
    • windows_98, windows_nt



      Name: bsC130419 Date: 05/31/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      After doing a rotate or shear transformation (either by calling
      g2d.transform(AffineTransform) or g2d.rotate(double) or by
      Font.deriveFont(AffineTransform) ), the Chinese characters become distorted.
      Here is a sample program:

      import java.io.*;
      import java.awt.*;
      import java.awt.font.*;
      import java.awt.geom.*;
      import javax.swing.*;

      public class Test {

      public static void main(String [] args) throws Exception {
      Font font = new Font("??????", Font.PLAIN, 20);
      font = font.deriveFont(40.0f);

      JFrame frame = new JFrame();
      JPanel panel = new TestPanel(font, new String("\u660e\u9ad4"));

      frame.getContentPane().add(panel);

      frame.setDefaultCloseOperation(3);
      frame.setSize(new Dimension(640, 480));
      frame.setVisible(true);
      }
      }

      class TestPanel extends JPanel {

      private Font font;
      private String str;


      public TestPanel(Font font, String str) {
      super();

      AffineTransform t = new AffineTransform();
      t.rotate(0.785);
      font = font.deriveFont(t);

      this.font = font;
      this.str = str;
      }


      public void paintComponent(Graphics g) {
      super.paintComponent(g);

      Graphics2D g2d = (Graphics2D)g;
      GlyphVector v =
      font.createGlyphVector(g2d.getFontRenderContext(), str);
      g2d.setFont(font);
      g2d.drawGlyphVector(v, 100, 100);
      }
      }


      The drawing is correct in JDK 1.3.0, JDK 1.3.0_01 and JDK 1.3.1
      (Review ID: 125274)
      ======================================================================

            sherman Xueming Shen
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: