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

Font.getStringBounds calculates wrong width for TextAttribute.TRACKING other than 0.0

XMLWordPrintable

    • 2d
    • 10
    • b19

        Font.getStringBounds calculates wrong width for TextAttribute.TRACKING other than 0.0

        Since JDK10, Font.getStringBounds calculates an incorrect width for a
        java.awt.font.Font with the TRACKING attribute set to a value other than
        0.0.

        This is not visibly evident in AWT/Swing, but can be checked by reading/printing
        Font.getStringBounds. It's also reproducible in a simple PDF rendering application.

        I have reproduced this issue in JDK11, 17 and 21, as well as confirming it is not
        present in JDK8 (jdk8u352-b08). I'll attach a reproducer.

        See also a small reproducer (PDF renderer) here:
        https://github.com/LibrePDF/OpenPDF/issues/796

              prr Philip Race
              jdowland Jonathan Dowland
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: