Red Hat Bugzilla – Bug 1478006
Invalid font metrics when printing under certain repeatable conditions
Last modified: 2018-05-03 04:52:43 EDT
Created attachment 1308721 [details]
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):
Steps to Reproduce:
I am attaching a test case and output PDF
Invalid font metrics when printing with some transparency on the page or using landscape orientation.
The metrics must always return valid values on all situations of portrait or landscape, transparency present or not.
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]
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'
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.