JDK-8274719 : TextLayout does not properly compute size or paint Soft Hyphen character
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 9,11,17
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2021-10-04
  • Updated: 2021-10-04
  • Resolved: 2021-10-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Description
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



Comments
Reported with JDK 17, java.awt.font.TextLayout class fails to paint a soft hyphen character. Checked this for reported version and confirmed the issue as reported. Result: ======== JDK 17 - Fail JDK 11 - Fail JDK 9 - Fail JDK 8u301 - Pass To verify, run the attached test case with respective JDK version. This is a regression introduced in JDK 9. Refer to attached screenshot for reported issue.
04-10-2021