-
Bug
-
Resolution: Duplicate
-
P3
-
9, 11.0.4
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
The spacing between some letters has extra whitespace. For example, the word "Options" has extra space between the "O" and the "p" making it look like there is an actual space between the letters -> "O ptions".
This is reproducible when using LCD antialiasing (horizontal or vertical depending on the orientation of your screen) when running with Java 9 through 12. It worked as expected in Java 8 and appears to have been addressed in Java 13 and later, but it would be good to have a backport to Java 11 as the LTS release.
REGRESSION : Last worked in version 8u221
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the ExtraWhitespace class (source code provided) with JDK 11 on Windows. The "Dialog" physical font should be mapped to "Arial" (the default). This is reproducible when using "Arial" directly as well.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Even spacing between letters in the words, especially between the "O" and "p".
ACTUAL -
Extra whitespace following the "O".
---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.RenderingHints;
import java.util.Objects;
import java.util.stream.Stream;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class ExtraWhitespace {
public static void main(String... args) {
JFrame frame = new JFrame("Extra Whitespace");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS));
frame.add(new JLabel("JDK Version: " + Runtime.version().toString()));
Stream.of(
RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON,
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR)
.map(ExtraWhitespace::createLabel)
.forEach(frame::add);
frame.pack();
frame.setVisible(true);
}
private static JLabel createLabel(Object aa) {
JLabel label = new JLabel(String.format("Options - %s", Objects.toString(aa)));
label.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
label.putClientProperty(RenderingHints.KEY_TEXT_ANTIALIASING, aa);
return label;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use a different font either in the code or via a custom font configuration file.
FREQUENCY : always
The spacing between some letters has extra whitespace. For example, the word "Options" has extra space between the "O" and the "p" making it look like there is an actual space between the letters -> "O ptions".
This is reproducible when using LCD antialiasing (horizontal or vertical depending on the orientation of your screen) when running with Java 9 through 12. It worked as expected in Java 8 and appears to have been addressed in Java 13 and later, but it would be good to have a backport to Java 11 as the LTS release.
REGRESSION : Last worked in version 8u221
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the ExtraWhitespace class (source code provided) with JDK 11 on Windows. The "Dialog" physical font should be mapped to "Arial" (the default). This is reproducible when using "Arial" directly as well.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Even spacing between letters in the words, especially between the "O" and "p".
ACTUAL -
Extra whitespace following the "O".
---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.RenderingHints;
import java.util.Objects;
import java.util.stream.Stream;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class ExtraWhitespace {
public static void main(String... args) {
JFrame frame = new JFrame("Extra Whitespace");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS));
frame.add(new JLabel("JDK Version: " + Runtime.version().toString()));
Stream.of(
RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON,
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR)
.map(ExtraWhitespace::createLabel)
.forEach(frame::add);
frame.pack();
frame.setVisible(true);
}
private static JLabel createLabel(Object aa) {
JLabel label = new JLabel(String.format("Options - %s", Objects.toString(aa)));
label.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
label.putClientProperty(RenderingHints.KEY_TEXT_ANTIALIASING, aa);
return label;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use a different font either in the code or via a custom font configuration file.
FREQUENCY : always
- duplicates
-
JDK-8217731 Font rendering and glyph spacing changed from jdk-8 to jdk-11
- Resolved
- relates to
-
JDK-8217731 Font rendering and glyph spacing changed from jdk-8 to jdk-11
- Resolved
-
JDK-8226215 JToggleButton text truncated with Windows L&F
- Closed