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

REGRESSION: Serious font problems under 1.3.0_02 and 1.3.1-beta

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.3.1
    • client-libs
    • 2d
    • x86
    • linux



      Name: yyT116575 Date: 03/08/2001


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

      Since JDK 1.3.0_02 and 1.3.1 font metrics are reported incorrectly and derived
      fonts created through transformations are rendered at the wrong location. Just
      test the following source under JDK 1.3.0 and compare the results with the other
      versions. I had these findings on several linux and windows workstations.

      /* BEGIN SOURCE test/TestGlyphvector.java */
      package test;

      import java.awt.*;
      import java.awt.event.*;
      import java.awt.font.*;
      import java.awt.geom.*;
      import java.awt.image.*;
      import javax.swing.*;

      public class TestGlyphvector extends WindowAdapter {

        static public void main(String[] args) {
          JFrame frame = new JFrame();
          frame.getContentPane().add(new TestPanel());
          frame.pack();
          frame.addWindowListener(new TestGlyphvector());
          frame.setVisible(true);
        }

        public void windowClosing(WindowEvent e) {
          e.getWindow().dispose();
        }

        public void windowClosed(WindowEvent e) {
          System.exit(0);
        }
      }

      class TestPanel extends JPanel {
        public TestPanel() {
          super();
          setPreferredSize(new Dimension(300, 300));
          setBackground(Color.white);
        }

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

          Graphics2D g2d = (Graphics2D)g;

          Font font = new Font("Helvetica", Font.PLAIN, 10);
          FontMetrics font_metrics = g2d.getFontMetrics(font);
          System.out.println("Ascent = "+font_metrics.getAscent());
          System.out.println("Descent = "+font_metrics.getDescent());
          System.out.println("Height = "+font_metrics.getHeight());
          System.out.println("Leading = "+font_metrics.getLeading());
                      
          g2d.setFont(font);
          g2d.drawString("testing", 100, 50);
          g2d.drawLine(0, 50, 300, 50);

          AffineTransform rotate_font_transform = AffineTransform.getRotateInstance(Math.toRadians(-90));
          Font font_rotated = font.deriveFont(rotate_font_transform);

          g2d.setFont(font_rotated);
          g2d.drawString("testing", 100, 100);
          g2d.drawLine(100, 0, 100, 300);

          FontRenderContext font_render_context = new FontRenderContext(null, true, true);
          GlyphVector glyph_vector = font_rotated.createGlyphVector(font_render_context, "testing");

          g2d.translate(100, 150);
          g2d.drawGlyphVector(glyph_vector, 0, 0);
          g2d.draw(glyph_vector.getVisualBounds());
        }
      }
      /* END SOURCE test/TestGlyphvector.java */

      The font metrics values that are output under 1.3.0 are :

      Ascent = 10
      Descent = 3
      Height = 13
      Leading = 0

      and under 1.3.0_02 and 1.3.1-beta :

      Ascent = 8
      Descent = 3
      Height = 11
      Leading = 0

      The graphical output under 1.3.0 produces the following :

      Non-derived font is drawn according to its baseline.
      Derived font is drawn according to its baseline too.
      The visual bounds of a created glyph vector include the visual text exactly.

      and under 1.3.0_02 and 1.3.1-beta :

      Non-derived font is drawn according to its baseline.
      Derived font is drawn according to the top of the text.
      The visual bounds of a created glyph vector don't correspond to the actual
      output of the text.
      (Review ID: 118096)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: