Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8274719

TextLayout does not properly compute size or paint Soft Hyphen character

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Introduced In Version:
      9
    • CPU:
      generic
    • OS:
      generic

      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


        Attachments

        1. jdk-17_result.PNG
          jdk-17_result.PNG
          2 kB
        2. jdk8u-result.PNG
          jdk8u-result.PNG
          2 kB
        3. TextLayoutBug.java
          1.0 kB

          Issue Links

            Activity

              People

              Assignee:
              prr Philip Race
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: