JDK-8269224 : Terribly broken font rendering with dejavu ttf
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 15,16
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2021-06-22
  • Updated: 2022-01-31
  • Resolved: 2022-01-31
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Reproducible with OpenJDK 15 and 16 (but not 11). Couldn't test other intermediate versions.

A DESCRIPTION OF THE PROBLEM :
When ttf-dejavu (https://dejavu-fonts.github.io/) is installed on the system, the text rendering is completely broken. I was unable to understand which fonts were exactly picked by fontconfig in the depicted scenario.

The issue is reproducible exclusively with all the java application on my system. No issue with any other text rendering engine.

REGRESSION : Last worked in version 11.0.11

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the sample code with TTF Dejavu installed on the system.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
4 lines of text with a consistent style and font: plain, italic, bold and bold+italic

See first picture on: https://imgur.com/a/3pPBRkr
ACTUAL -
1. the first line has some bold
2. the first line uses a different font between digits+parenthesis and the other characters
3. the 2nd line has a glitchy "M" and "N" characters
4. the 4th line should not have a non-bold characters like the "1", "E", "F", "H", etc.

See 2nd picture on: https://imgur.com/a/3pPBRkr

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class BugText extends Frame {

   public BugText(){
      setSize(1200, 400);
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent windowEvent){
            System.exit(0);
         }
      });
   }

   public static void main(String[] args){
      BugText bugtext = new BugText();
      bugtext.setVisible(true);
   }

   private String test_str = "abcdefghijklmnopqrstuvwxyz 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ !@#$%^&*()_+";
   private int font_size = 22;

   @Override
   public void paint(Graphics g) {
      Graphics2D g2 = (Graphics2D)g;
      Font plainFont = new Font("Serif", Font.PLAIN, font_size);
      System.out.println(plainFont);
      System.out.println(plainFont.getNumGlyphs());
      g2.setFont(plainFont);
      g2.drawString(test_str, 10, 70);

      Font italicFont = new Font("Serif", Font.ITALIC, font_size);
      System.out.println(italicFont);
      System.out.println(italicFont.getNumGlyphs());
      g2.setFont(italicFont);
      g2.drawString(test_str, 10, 120);

      Font boldFont = new Font("Serif", Font.BOLD, font_size);
      System.out.println(boldFont);
      System.out.println(boldFont.getNumGlyphs());
      g2.setFont(boldFont);
      g2.drawString(test_str, 10, 170);

      Font boldItalicFont = new Font("Serif", Font.BOLD+Font.ITALIC, font_size);
      System.out.println(boldItalicFont);
      System.out.println(boldItalicFont.getNumGlyphs());
      g2.setFont(boldItalicFont);
      g2.drawString(test_str, 10, 220);

   }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Uninstall ttf-dejavu

FREQUENCY : always



Comments
Duplicates to JDK-8264703
23-06-2021