JDK-8217712 : Synthesize Italic Font Faces
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 11
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-01-22
  • Updated: 2020-08-11
  • Resolved: 2020-08-11
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 10 10.0.17134 Build 17134
Occurs using JDK and OpenJDK version 11.0.2
Does not occur using JDK 8u201

A DESCRIPTION OF THE PROBLEM :
When calling Graphics2D.drawString() with a Font that should be ITALIC but does not have an installed italic font face, the text is rendered without an oblique style.  When running with JDK 8, the italic font face is synthesized.  

REGRESSION : Last worked in version 8u181

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Find an installed font that does not have an italic font face (Impact is a good choice for Windows)
2. Create a new font object with the font from step 1 ( new Font("Impact", Font.ITALIC, 18); )
3. Create or get a Graphics2D object ( bufferedImage.createGraphics() )
4. set the font from step 2 on the graphics object from step 3 ( g.setFont(font) )
5. draw a String ( g.drawString(...) )

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The displayed text has an oblique style.
ACTUAL -
The displayed text is not oblique and instead appears like it was rendered as Font.PLAIN (or Font.BOLD when bold italic is desired).

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class SimpleFontTest {
	private static Font FONT = new Font("Impact", Font.ITALIC, 18);
	private static String TEXT = "The Quick Brown Fox";

	public static void main(String args[]){		
		if (args.length > 0 && args[0] != null) {
			String fontName = args[0];
			FONT = new Font(fontName, Font.ITALIC, 18);
		}

		JFrame f = new JFrame("Simple Font Test: " + System.getProperty("java.vendor"));
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JLabel label = new JLabel("JLabel: " + TEXT);
		label.setFont(FONT);
		
		System.out.println(System.getProperty("java.vendor"));
		System.out.println(System.getProperty("java.version"));

		GraphicsConfiguration gc = f.getGraphicsConfiguration();
		BufferedImage image = gc.createCompatibleImage(400, 50);
		Graphics2D g = image.createGraphics();
		g.setFont(FONT);
		g.setColor(Color.BLACK);
		g.setBackground(Color.WHITE);
		g.clearRect(0, 0, image.getWidth(), image.getHeight());
		g.drawString("BufferedImage: " + TEXT, 10, 15);
		g.dispose();
		JLabel picLabel = new JLabel(new ImageIcon(image));

		f.add(label, BorderLayout.PAGE_START);
		f.add(picLabel, BorderLayout.CENTER);
		f.setSize(400, 200);
		f.setVisible(true);
	}
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Closing this as a duplicate of JDK-8214002.
11-08-2020

The issue is not reproducible with 11.0.8, text rendered fine with oblique style as expected. This is fixed in 11.0.6-oracle.
11-08-2020

This is probably a duplicate of https://bugs.openjdk.java.net/browse/JDK-8214002
29-05-2019

This seems a regresison introduced in JDK 11, but seems to be fixed in JDK 12. (See attached screenshot as reference). Writing back to the submitter requesting status with JDK 12 ea build at his end. Result: ======== 8u201: Pass 10.0.2: Pass 11: Fail 11.0.2: Fail 12 ea b29: Pass 13 ea b04: Pass
24-01-2019