-
Bug
-
Resolution: Not an Issue
-
P3
-
8, 11.0.6, 15, 16
ADDITIONAL SYSTEM INFORMATION :
Windows 10
OpenJDK 11.0.8 and OpenJDK 15.0.1
A DESCRIPTION OF THE PROBLEM :
When drawing a String in an undecorated dialog with a transparent background with the font family 'Segoe UI' the String looks distorted (quasi bold) in comparison to the String drawn in a normal frame.
This seems to be a problem with the text antialiasing. This worked correctly in OpenJDK 11.0.2 and is broken at least since OpenJDK 11.0.4.
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached source code example to see the problem
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The String rendered in the window opened when pressing the button looks the same as the String rendered under the button.
ACTUAL -
The String rendered in the window opened when pressing the button looks different from the String rendered under the button (looks quasi bold).
---------- BEGIN SOURCE ----------
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JWindow;
import javax.swing.WindowConstants;
import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public final class AwtSample {
private static final Font FONT_SEGOE_UI = new Font("Segoe UI", Font.PLAIN, 13);
public static void main(String[] args) {
JFrame frame = new JFrame("Sample");
frame.setSize(500, 200);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Button button = new Button("Click me");
button.setBackground(Color.WHITE);
button.addActionListener(__ -> {
JWindow dialog = new JWindow();
dialog.setSize(110, 110);
dialog.setLocationRelativeTo(button);
dialog.setBackground(new Color(255, 255, 255, 0));
Component canvas = createCanvas();
dialog.add(canvas);
dialog.setVisible(true);
});
Container contentPane = frame.getContentPane();
contentPane.setBackground(Color.WHITE);
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.add(button);
contentPane.add(createCanvas());
frame.setVisible(true);
}
private static Component createCanvas() {
Component canvas = new Component() {
@Override
public void paint(Graphics g) {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
super.paint(g);
g.setFont(FONT_SEGOE_UI);
g.drawString("Test", 12, 50);
}
};
canvas.setSize(100, 100);
return canvas;
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows 10
OpenJDK 11.0.8 and OpenJDK 15.0.1
A DESCRIPTION OF THE PROBLEM :
When drawing a String in an undecorated dialog with a transparent background with the font family 'Segoe UI' the String looks distorted (quasi bold) in comparison to the String drawn in a normal frame.
This seems to be a problem with the text antialiasing. This worked correctly in OpenJDK 11.0.2 and is broken at least since OpenJDK 11.0.4.
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached source code example to see the problem
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The String rendered in the window opened when pressing the button looks the same as the String rendered under the button.
ACTUAL -
The String rendered in the window opened when pressing the button looks different from the String rendered under the button (looks quasi bold).
---------- BEGIN SOURCE ----------
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JWindow;
import javax.swing.WindowConstants;
import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public final class AwtSample {
private static final Font FONT_SEGOE_UI = new Font("Segoe UI", Font.PLAIN, 13);
public static void main(String[] args) {
JFrame frame = new JFrame("Sample");
frame.setSize(500, 200);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Button button = new Button("Click me");
button.setBackground(Color.WHITE);
button.addActionListener(__ -> {
JWindow dialog = new JWindow();
dialog.setSize(110, 110);
dialog.setLocationRelativeTo(button);
dialog.setBackground(new Color(255, 255, 255, 0));
Component canvas = createCanvas();
dialog.add(canvas);
dialog.setVisible(true);
});
Container contentPane = frame.getContentPane();
contentPane.setBackground(Color.WHITE);
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.add(button);
contentPane.add(createCanvas());
frame.setVisible(true);
}
private static Component createCanvas() {
Component canvas = new Component() {
@Override
public void paint(Graphics g) {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
super.paint(g);
g.setFont(FONT_SEGOE_UI);
g.drawString("Test", 12, 50);
}
};
canvas.setSize(100, 100);
return canvas;
}
}
---------- END SOURCE ----------
FREQUENCY : always