Bug 1478006 - Invalid font metrics when printing under certain repeatable conditions
Invalid font metrics when printing under certain repeatable conditions
Product: Fedora
Classification: Fedora
Component: java-1.8.0-openjdk (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Mario Torre
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2017-08-03 08:48 EDT by Robert Marcano
Modified: 2018-05-03 04:52 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Test output (86.17 KB, application/pdf)
2017-08-03 08:48 EDT, Robert Marcano
no flags Details
Test case (4.72 KB, text/x-csrc)
2017-08-03 08:50 EDT, Robert Marcano
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
openjdk bug system JDK-8139178 None None None 2017-08-03 11:38 EDT

  None (edit)
Description Robert Marcano 2017-08-03 08:48:28 EDT
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):


How reproducible:


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.
Comment 1 Robert Marcano 2017-08-03 08:50 EDT
Created attachment 1308723 [details]
Test case

Adding the test that generated the PDF
Comment 2 Robert Marcano 2017-08-03 11:38:03 EDT
I was referred to an old OpenJDK bug (so sad it is that old). Added it to this bug
Comment 3 Robert Marcano 2017-08-03 15:05:24 EDT
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.
Comment 4 Fedora End Of Life 2018-05-03 04:26:27 EDT
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.
Comment 5 Mario Torre 2018-05-03 04:52:43 EDT
I'm keeping this alive since the bug appears still not fixed upstream even in 9 and 10.

Note You need to log in before you can comment on or make changes to this bug.