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

freetype incorrectly adjusts advances when emboldening rotated glyphs

    XMLWordPrintable

Details

    • 2d
    • 11
    • b21
    • x86_64
    • windows_10
    • Verified

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Tested on Windows 10 and OpenJDK 14 ea.

      A DESCRIPTION OF THE PROBLEM :
      If we draw a bold string using Graphic2D#rotate and Grahic2D#drawString, the each characters are drawn gradually going upper locations compared to the baseline.

      This seems different depending on the font that is used to draw the string. In my environment the OS is the Japanese version of Windows 10. In such environment, if the font is "Dialog" only BOLD and wide characters are drawn at wrong positions. However, if we use "MS P Gothic" as a font, even normal alphabet characters are drawn at wrong positions.

      This does not happen with Oracle JDK 8, but does happen with Oracle JDK 13 and OpenJDK 11, 12, 13, 14 ea.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please run the code I attach in the "Source code for an executable test case".

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All of the text lines are drawn parallelly, regardless of the rotated angle.
      ACTUAL -
      Bold strings gradually goes upper direction, so the positions of the characters go away from the plain texts, or overlap with the plain texts.

      ---------- BEGIN SOURCE ----------
      import java.awt.Color;
      import java.awt.Font;
      import java.awt.Graphics;
      import java.awt.Graphics2D;

      import javax.swing.JFrame;
      import javax.swing.JPanel;

      public class Hoge extends JPanel {

      public static void main(String[] args){

      String text = System.getProperty("java.vendor") + " " + System.getProperty("java.version");

      JFrame frame= new JFrame(text);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().add(new Hoge());
      frame.setSize(1000, 1000);
      frame.setVisible(true);
      }

      public void paint(Graphics g){

      Graphics2D g2 = (Graphics2D)g;

      String fontName = "MS Pゴシック";
      int fontSize = 20;
      int posY=25;

      for(int i=0;i<3;i++){
      posY=25;
      if(i==0){
      g2.setColor(Color.BLACK);
      fontName = "Dialog";
      }if(i==1){
      g.translate(200, 100);
      g2.rotate(0.8);
      g2.setColor(Color.red);
      }else if(i==2){
      g2.setColor(Color.BLUE);
      fontName = "MS Pゴシック";
      g.translate(200, -200);
      }

      g2.setFont(new Font(fontName, Font.BOLD, fontSize));
      g2.drawString("THIS IS A HALF-WIDTH AND BOLD STRING. FONT=" + fontName , 50, posY+=25);

      g2.setFont(new Font(fontName, Font.BOLD, fontSize));
      g2.drawString("THIS IS A NON-HALF AND BOLD STRING. FONT==" + fontName, 50, posY+=25);

      g2.setFont(new Font(fontName,Font.PLAIN, fontSize));
      g2.drawString("THIS IS A NON-HALF AND PLAIN STRING. FONT==" + fontName, 50, posY+=25);

      g2.setFont(new Font(fontName, Font.BOLD, fontSize));
      g2.drawString("THIS IS A HALF-WIDTH AND BOLD STRING. FONT=" + fontName , 50, posY+=25);
      }

      }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        1. 14ea.png
          14ea.png
          40 kB
        2. 8u231.png
          8u231.png
          42 kB
        3. Hoge.java
          2 kB

        Activity

          People

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: