RFR: 6562639: Wrong pixel bounds from TextLayout with white font [v2]
Daniel Gredler
dgredler at openjdk.org
Fri Jan 2 10:46:49 UTC 2026
> One of the possible code paths for `TextLayout.getPixelBounds(...)` actually draws the text on a `Graphics2D` and checks the image pixels afterwards. The text is drawn over a white background, so if the user sets the font's foreground color to white then the text pixels cannot be detected (white on white).
>
> This PR fixes the issue by removing the code that sets the background to white, leaving the background as the default ARGB color (0 = transparent black). This does not cause a new problem for users who might set their font foreground color to transparent black, because transparent font foreground colors always return an empty bounds anyway (by virtue of being transparent).
>
> The updated code should also be slightly faster since it's doing less work, though I haven't run any performance tests.
Daniel Gredler has updated the pull request incrementally with one additional commit since the last revision:
Update copyright year 2025 -> 2026
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/28809/files
- new: https://git.openjdk.org/jdk/pull/28809/files/ad0ff83a..dbac4944
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=28809&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=28809&range=00-01
Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/28809.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28809/head:pull/28809
PR: https://git.openjdk.org/jdk/pull/28809
More information about the client-libs-dev
mailing list