[OpenJDK 2D-Dev] FontMetrics differ between OracleJDK 8 and OpenJDK 11
jacob_tredinnick at mentor.com
Mon Jan 7 15:53:10 UTC 2019
I hope that you our someone else on this mail list can help us out here because this change has quite a big impact on our Java upgrade.
While waiting for your return I have done some more investigation into the diffs that we see between the font metrics with OracleJDK 8 (what we currently use) and OpenJDK 11 (what we need to migrate to).
I have attached a PDF of the investigation but I'm not sure if that can get through the mail list (please forgive my ignorance of how the mail list handles attachments).
I generated font metrics for all fonts on my system (except Lucida fonts as they were causing some difficulty with the comparison), with sizes 1-48 and all 4 combinations of style.
That results in 88512 combinations from the 461 fonts on my Windows 7 laptop.
I subtracted the OracleJDK 8 values from the OpenJDK 11 values for the various FontMetrics methods and I think I can see a couple of significant patterns in the data:
1. The font baseline is moving significantly upwards for a number of fonts including Calibri.
2. Differences are usually the same but sometimes only one for a number of metrics including getHeight.
There are more details in the attached PDF but here are some findings backing up my conclusions for anyone reading this without the attachment.
All comments refer to the diffs obtained by subtracting the OracleJDK 8 values from the OpenJDK 11 values:
* getMaxAscent is virtually always equal or lower while getMaxDescent is always equal or higher.
* Several measures are usually the same but sometimes off by one suggesting rounding errors either in T2K or FreeType: getHeight, getLeading, (getMaxAscent+getMaxDescent).
* getMaxAdvance is either lower by 1, equal or varying degrees larger. We have seen diffs in character spacing, but these have so far been acceptable.
We still don't really understand how a difference in font metrics for the same font on the same computer isn't a bug & we are keen to reach a conclusion at least on whether Oracle accepts this as a bug.
From: Philip Race [mailto:philip.race at oracle.com]
Sent: 02 January 2019 18:38
To: Tredinnick, Jacob <jacob_tredinnick at mentor.com>
Cc: 2d-dev at openjdk.java.net
Subject: Re: [OpenJDK 2D-Dev] FontMetrics differ between OracleJDK 8 and OpenJDK 11
I am on vacation for (another) week but it is possible that what
you are describing is a bug whereby a transformation that is in effect
was not inverted before returning metrics to the application.
This notably affected rotations but could be in play here too although
I haven't tested this. It was fixed very recently so you will need to try a
JDK 12 EA build here : https://jdk.java.net/12/
On 1/2/19, 8:44 AM, Tredinnick, Jacob wrote:
Default scaling options are "Medium - 125%" on Windows 7. You are correct this does affect things but read on...
Basically, we are using these FontMetrics values to determine a scale transformation to apply to a size 12 font. HDPI might be playing in somewhere here, but the problem we know about is with our use of FontMetrics.
I wrote some code to demonstrate our problem (source at the end of this message). The application shows:
* An example string drawn using java.awt.Graphics#drawString(java.lang.String, int, int) with a "normal" font object: Calibri plain, size 12
* The same string drawn based on a Font that is "scaled" (nothing to do with HDPI) using a simplified version of what our application does with the FontMetrics object (we also have zoom levels and users may specify their font sizes in various ways)
* 2 rectangles with sizes hard-coded to wrap these texts when run on my system with OracleJDK 8 (what our applications currently use), for use when comparing the screenshots
-------------- next part --------------
An HTML attachment was scrubbed...
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 50187 bytes
More information about the 2d-dev