-
Bug
-
Resolution: Duplicate
-
P3
-
9, 11, 17
ADDITIONAL SYSTEM INFORMATION :
Any OS, Open JDK 17
A DESCRIPTION OF THE PROBLEM :
The java.awt.font.TextLayout class when used to paint a soft hyphen character, does not paint it and it considers it to have zero width.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a swing JLabel and use TextLayout to draw a string which contains the soft hyphen char.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The soft hyphen char should be drawn.
ACTUAL -
The soft hyphen char is not drawn.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
JFrame fr = new JFrame("abc");
JLabel label = new JLabel() {
/**
* @see javax.swing.JComponent#paint(java.awt.Graphics)
*/
@Override
public void paint(Graphics g) {
FontRenderContext frc = new FontRenderContext(null, true, false);
String string = "abc\u00addef";
TextLayout tl = new TextLayout(string, getFont(), frc);
tl.draw((Graphics2D) g, 0, 15);
}
};
label.setFont(new Font("Serif", Font.PLAIN, 15));
fr.setSize(500, 500);
fr.getContentPane().add(label);
fr.setVisible(true);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This works with Java 8 but not with Java 17.
FREQUENCY : always
Any OS, Open JDK 17
A DESCRIPTION OF THE PROBLEM :
The java.awt.font.TextLayout class when used to paint a soft hyphen character, does not paint it and it considers it to have zero width.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a swing JLabel and use TextLayout to draw a string which contains the soft hyphen char.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The soft hyphen char should be drawn.
ACTUAL -
The soft hyphen char is not drawn.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
JFrame fr = new JFrame("abc");
JLabel label = new JLabel() {
/**
* @see javax.swing.JComponent#paint(java.awt.Graphics)
*/
@Override
public void paint(Graphics g) {
FontRenderContext frc = new FontRenderContext(null, true, false);
String string = "abc\u00addef";
TextLayout tl = new TextLayout(string, getFont(), frc);
tl.draw((Graphics2D) g, 0, 15);
}
};
label.setFont(new Font("Serif", Font.PLAIN, 15));
fr.setSize(500, 500);
fr.getContentPane().add(label);
fr.setVisible(true);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This works with Java 8 but not with Java 17.
FREQUENCY : always
- duplicates
-
JDK-8208377 Soft hyphens render if not using TextLayout
- Open