Integrated: 8339974: Graphics2D.drawString doesn't always work with Font derived from AffineTransform
Daniel Gredler
duke at openjdk.org
Thu Oct 10 18:03:19 UTC 2024
On Fri, 13 Sep 2024 10:06:59 GMT, Daniel Gredler <duke at openjdk.org> wrote:
> There is a bug in `TextLayout.getOutline(AffineTransform)`, where the transformation is applied too early (before the layout path applies its mapping). The most obvious error caused by this bug is that `Graphics2D.drawString(...)` fails to draw the string when using a rotated + scaled `AffineTransform` (see minimal test case in the bug report).
>
> There are two uses of `TextLayout.getOutline(AffineTransform)`: the first one, triggered via a simple `Graphics2D.drawString(...)` was the one I ran into; the second one requires the use of a transformed font with a `PSPrinterJob`. Both are broken. This PR includes two test classes verifying that both scenarios were broken before the fix and are working after the fix.
>
> Two points which might require some discussion:
> 1. I've changed the signature of method `TextLine.getOutline(AffineTransform)`, to just `TextLine.getOutline()`; I'm assuming this is OK since `TextLine` is a package-private class.
> 2. I've added a fast path in `TextLayout.getOutline(AffineTransform)` to transform the shape in place if it is a `GeneralPath` (it should usually be, and avoids an extra `Shape` copy vs. the current code, which makes no copy). A bit more complex, but efficient.
This pull request has now been integrated.
Changeset: 2a6f0307
Author: Daniel Gredler <daniel.gredler at gmail.com>
Committer: Phil Race <prr at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/2a6f0307e8d287fc9177e9454386e63faf8e61a0
Stats: 375 lines in 4 files changed: 369 ins; 4 del; 2 mod
8339974: Graphics2D.drawString doesn't always work with Font derived from AffineTransform
Reviewed-by: prr, azvegint
-------------
PR: https://git.openjdk.org/jdk/pull/20993
More information about the client-libs-dev
mailing list