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

Jonathan Dowland jdowland at openjdk.org
Wed Apr 5 14:08:22 UTC 2023


This is one proposed solution for https://bugs.openjdk.org/browse/JDK-8304350

`java.awt.Font.getStringBounds(char[],int,int,FontRenderContext)` applies a heuristic to determine whether the question it's answering is "simple" or not. The bug described in 8304350 only occurs in the simple=true branch.

Extend the "simple?" heuristic to consider a tracking attribute not-simple and to use the complex branch in those cases.

One could argue that the root bug still exists: the simple path goes on to delegate to `sun.font.FontDesignMetrics.getMetrics(Font,FontRenderContext)`, although that's a private/internal API.

-------------

Commit messages:
 - 8304350: Font.getStringBounds calculates wrong width for TextAttribute.TRACKING other than 0.0

Changes: https://git.openjdk.org/jdk/pull/13352/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13352&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8304350
  Stats: 4 lines in 1 file changed: 2 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/13352.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13352/head:pull/13352

PR: https://git.openjdk.org/jdk/pull/13352



More information about the client-libs-dev mailing list