Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8256264: Printed GlyphVector outline with low DPI has bad quality on Windows #1183

Closed

Conversation

AlexanderScherbatiy
Copy link

@AlexanderScherbatiy AlexanderScherbatiy commented Nov 12, 2020

Printing text using GlyphVector outline has bad quality on printers with low DPI on Windows.
The GDI system used for text printing on Windows accepts only integer path coordinates.
Rounding GlyphVector outline coordinates leads to distorted printed text.

To reproduce the issue run the PrintGlyphVectorOutlineSample file on Windows and select a low DPI
printer in the printer dialog. The sample prints two lines, one using Graphics drawString() method and another by
filling GlyphVector outline. Chars on the second line are distorted.

It is also possible to reproduce the issue running the sample and printing the text to PDF: fill-glyph-vector-outline.png

The proposed fix introduce "sun.java2d.print.enablePathPrecisionScale" property which being enabled
scales the GDI WorldTransform down and GlyphVector outline coordinates up.
This allows to keep some digits after a dot from being rounded.
The value for scaling is chosen to be 1000 in the same way how it is used by String trunc(float f) method from PSPrinterJob class on Linux:

See the fill-glyph-vector-outline-enable-path-scale-factor.png screenshot which shows how the GlyphVector outline is filled after the fix with the enabled "sun.java2d.print.enablePathPrecisionScale" option.

fill-glyph-vector-outline-diff.png shows difference of GlyphVector outline printing before and after the fix.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8256264: Printed GlyphVector outline with low DPI has bad quality on Windows

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/1183/head:pull/1183
$ git checkout pull/1183

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 12, 2020

👋 Welcome back alexsch! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 12, 2020
@openjdk
Copy link

openjdk bot commented Nov 12, 2020

@AlexanderScherbatiy The following labels will be automatically applied to this pull request:

  • 2d
  • awt

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added 2d client-libs-dev@openjdk.org awt client-libs-dev@openjdk.org labels Nov 12, 2020
@mlbridge
Copy link

mlbridge bot commented Nov 12, 2020

Webrevs

@mrserb
Copy link
Member

mrserb commented Nov 20, 2020

I am not sure that we need the additional property for things other than possibly to workaround some possible bugs. I am fine if we will use the scaled version all the time, does it have any drawbacks?

@AlexanderScherbatiy
Copy link
Author

I prepared a simple print test sample which uses 4 different fonts (plain and bold) with different sizes and prints 640 lines on 10 pages.

I run the sample with and without the fix to PDF and measured the time which is used by the deviceFill() method (it both converts the shape to path and fills it):

protected void deviceFill(PathIterator pathIter, Color color) {

The average time without the fix: 2.77s (min 2.74s, max 2,78)
The average time with the fix: 2.76s (min 2.74s, max 2.77)

I removed the sun.java2d.print.enablePathPrecisionScale property from the fix.

@mrserb
Copy link
Member

mrserb commented Nov 28, 2020

I removed the sun.java2d.print.enablePathPrecisionScale property from the fix.

You forgot to delete it from the test.

@AlexanderScherbatiy
Copy link
Author

The sun.java2d.print.enablePathPrecisionScale property is removed from the PathPrecisionScaleFactorTest test.

mrserb
mrserb approved these changes Nov 30, 2020
@openjdk
Copy link

openjdk bot commented Nov 30, 2020

@AlexanderScherbatiy This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8256264: Printed GlyphVector outline with low DPI has bad quality on Windows

Reviewed-by: serb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 378 new commits pushed to the master branch:

  • 2b4a423: 8255542: Attribute length of Module, ModulePackages and other attributes is ignored
  • ca40267: 8257509: Strengthen requirements to call G1HeapVerifier::verify(VerifyOption)
  • 4a85514: 8257182: JCK test failures in integer / long rotation tests
  • f33808f: 8257631: C2: Assertion failure in ArrayCopyNode::get_count() during late inlining
  • 417e7e6: 8257632: C2: Late inlining attempt on a call with a dead memory crashes
  • 6845fee: 8257625: C2: Harden input checks in vector intrinsics
  • 4390f2c: 8257630: C2: ReplacedNodes doesn't handle non-CFG multi nodes
  • d08c612: 8257708: Remove redundant unmodifiableSet wrapper from already immutable set returned by Collections.singleton
  • 49f9e57: 8257734: Extraneous output in HmacSHA3_512 constructor
  • f83fd4a: 8257438: Avoid adding duplicate values into extendedKeyCodesSet
  • ... and 368 more: https://git.openjdk.java.net/jdk/compare/ec08b3f28d133c2cc8a9cb8396c5bfa36333ff98...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 30, 2020
@AlexanderScherbatiy
Copy link
Author

/integrate

@openjdk openjdk bot closed this Dec 4, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 4, 2020
@openjdk
Copy link

openjdk bot commented Dec 4, 2020

@AlexanderScherbatiy Since your change was applied there have been 378 commits pushed to the master branch:

  • 2b4a423: 8255542: Attribute length of Module, ModulePackages and other attributes is ignored
  • ca40267: 8257509: Strengthen requirements to call G1HeapVerifier::verify(VerifyOption)
  • 4a85514: 8257182: JCK test failures in integer / long rotation tests
  • f33808f: 8257631: C2: Assertion failure in ArrayCopyNode::get_count() during late inlining
  • 417e7e6: 8257632: C2: Late inlining attempt on a call with a dead memory crashes
  • 6845fee: 8257625: C2: Harden input checks in vector intrinsics
  • 4390f2c: 8257630: C2: ReplacedNodes doesn't handle non-CFG multi nodes
  • d08c612: 8257708: Remove redundant unmodifiableSet wrapper from already immutable set returned by Collections.singleton
  • 49f9e57: 8257734: Extraneous output in HmacSHA3_512 constructor
  • f83fd4a: 8257438: Avoid adding duplicate values into extendedKeyCodesSet
  • ... and 368 more: https://git.openjdk.java.net/jdk/compare/ec08b3f28d133c2cc8a9cb8396c5bfa36333ff98...master

Your commit was automatically rebased without conflicts.

Pushed as commit d6dd440.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2d client-libs-dev@openjdk.org awt client-libs-dev@openjdk.org integrated Pull request has been integrated
2 participants