Created attachment 1308721 [details] Test output Description of problem: When doing Java Printing API with Java2D, font metrics for ascent and descent return negative or zero values under certain conditions: 1. If the page is printer landscape it return zero for both metrics properties. 2. If the page contains transparency (when the page is sent to the printer as an image) it returns negative values. The landscape problem has greater preference than the one with a transparency, so a landscape page with a transparency return zero. Version-Release number of selected component (if applicable): java-1.8.0-openjdk-1.8.0.141-1.b16.fc26.x86_64 How reproducible: Always. Steps to Reproduce: I am attaching a test case and output PDF Actual results: Invalid font metrics when printing with some transparency on the page or using landscape orientation. Expected results: The metrics must always return valid values on all situations of portrait or landscape, transparency present or not. Additional info: The bug doesn't happen on Oracle JVMs that use a proprietary font layout code. The test PDF has 4 pages, 1 and 2 are portrait, 3 and 4 are landscape (page 4 is really landscape printed but the viewer will show it portrait, it is Ghostcript's ps2pdf automatic orientation algorithm in action) - Page 1 is the only one with correct positive values and is shown perfectly. - Page 2 is invalid with negative values because is has transparency. - Page 3 is invalid with zero as values because they are landscape.
Created attachment 1308723 [details] Test case Adding the test that generated the PDF
I was referred to an old OpenJDK bug (so sad it is that old). Added it to this bug
For the record, there is a workaround if the client code is accessible: Use LineMetrics instead of FontMetrics to get ascent and descent. It is probably better to use those when printing because LineMetrics returns float values instead of int of FontMetrics and Java printing is fixed at 72 dpi but real printers has greater resolutions so subpixel font metrics are better. But for closed source applications or that developers don't want to update the fix is needed.
This message is a reminder that Fedora 26 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 26. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '26'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 26 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
I'm keeping this alive since the bug appears still not fixed upstream even in 9 and 10.
This comment was flagged a spam, view the edit history to see the original text if required.
This message is a reminder that Fedora 28 is nearing its end of life. On 2019-May-28 Fedora will stop maintaining and issuing updates for Fedora 28. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '28'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 28 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 28 changed to end-of-life (EOL) status on 2019-05-28. Fedora 28 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.