RFR: 8349932: PSPrinterJob sometimes generates unnecessary PostScript commands
Daniel Gredler
dgredler at openjdk.org
Wed Mar 5 14:21:53 UTC 2025
On Fri, 14 Feb 2025 20:41:02 GMT, Phil Race <prr at openjdk.org> wrote:
>> Trying to print text which is ignored (e.g. `\r` or `\n` or `\t`), or trying to print empty shapes generates PostScript graphics context setup commands which are not necessary. This can lead to unnecessarily large PostScript files, and can complicate analysis / comparison of these files.
>>
>> Two methods are impacted:
>>
>> `PSPrinterJob.textOut(...)`: The `prepDrawing()` method should only be called once all sanity checks have passed. Otherwise, it will add PS graphics context setup commands that may not be necessary.
>>
>> `PSPrinterJob.deviceFill(...)`: This method should do nothing if the provided `PathIterator` is empty. Otherwise, it will add PS graphics context setup commands that are not necessary.
>>
>> The changes in `PSPrinterJob.textOut(...)` eliminated a big `if` statement, therefore include some indentation changes. Checking the diff with whitespace ignored should be helpful here.
>>
>> A test case is included.
>
> The new test failed on Windows
> java.lang.RuntimeException: Expected 1 path, but found 0 paths
> at PostScriptLeanTest.main(PostScriptLeanTest.java:80)
> at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
> at java.base/java.lang.reflect.Method.invoke(Method.java:565)
> at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
> at java.base/java.lang.Thread.run(Thread.java:1447)
@prrace This one is ready for a second review, if you have time.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23595#issuecomment-2701082666
More information about the client-libs-dev
mailing list