RFR: 8251928: [macos] the printer DPI always be 72, cause some content lost when print out [v2]
GennadiyKrivoshein
duke at openjdk.org
Tue Jul 22 07:06:00 UTC 2025
> The fix for the https://bugs.openjdk.org/browse/JDK-8251928.
>
> **Description**.
> This PR contains changes to be able to print with DPI higher than 72 on macOS, set default CPrinterJob DPI is 300 like in the PSPrinterJob.
>
> As described in the macOS drawing guide, the following steps are required to draw with high DPI (https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html#//apple_ref/doc/uid/TP40003290-CH204-BCICIJAJ):
> 1. Convert the user-space point, size, or rectangle value to device space coordinates;
> 2. Normalize the value in device space so that it is aligned to the appropriate pixel boundary;
> 3. Convert the normalized value back to user space;
> 4. Draw your content using the adjusted value.
>
> The 1-st step is now implemented in the CPrinterJob, a Graphics provided to the print method adjusted to a printer's DPI.
> The 2-nd step is a drawing process in the java code (without changes).
> The 3-rd step is now implemented in the PrinterView.m, the drawing scaled back to the 72 DPI.
> The 4-th step is a drawing process in the native code (without changes).
>
> **Tests**.
> I run all tests from javax.print package and there is no any regression.
> New test covers macOS and Linux only because we know its default DPI - 300.
GennadiyKrivoshein has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
- Merge branch 'openjdk:master' into macOS_printing_DPI
- [macos] the printer DPI always be 72
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/25489/files
- new: https://git.openjdk.org/jdk/pull/25489/files/05568097..3d61732d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=25489&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=25489&range=00-01
Stats: 145880 lines in 3016 files changed: 87538 ins; 36017 del; 22325 mod
Patch: https://git.openjdk.org/jdk/pull/25489.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25489/head:pull/25489
PR: https://git.openjdk.org/jdk/pull/25489
More information about the client-libs-dev
mailing list