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

Thomas Stuefe stuefe at openjdk.org
Thu Apr 13 06:08:41 UTC 2023


On Wed, 5 Apr 2023 13:58:48 GMT, Jonathan Dowland <jdowland at openjdk.org> wrote:

> 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.

This is fine as a workaround. If we find the root cause of this problem we can remove it.

Cheers, Thomas

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

Marked as reviewed by stuefe (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13352#pullrequestreview-1382688383



More information about the client-libs-dev mailing list