JDK-8017773 : OpenJDK7 returns incorrect TrueType font metrics
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7,8,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_oracle_6.0
  • Submitted: 2013-06-25
  • Updated: 2019-10-31
  • Resolved: 2014-09-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u60Fixed 9 b36Fixed openjdk7uFixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
Java HotSpot(TM) 64-Bit Server VM 1.7.0_19

ADDITIONAL OS VERSION INFORMATION :
RedHat Enterprise Linux 6.4

A DESCRIPTION OF THE PROBLEM :
The getAscent() and the getDescent() in java.awt.FontMetrics Class of OpenJDK1.7 returns incorrect TrueType font metrics.

Here is the comparison table.

**********************************
Oracle Corporation
OpenJDK 65-Bit Server VM
1.7.0_19
**********************************
font namefont stylefont sizeascentdescent

IPAMinchoBOLD9.191
IPAMinchoBOLD10.3102
IPAMinchoBOLD11.4112
IPAMinchoBOLD12.5122
IPAMinchoBOLD13.6132
IPAMinchoBOLD13.7132
IPAMinchoBOLD14.7142
IPAMinchoBOLD14.8142
IPAMinchoBOLD15.8152
IPAMinchoBOLD15.9152
IPAMinchoBOLD17162
IPAMinchoBOLD17.1162
IPAMinchoBOLD18.1172
IPAMinchoBOLD18.2172



**********************************
Sun Microsystems Inc.
Java HotSpot(TM) 64-Bit Server VM
1.6.0_38
**********************************
font namefont stylefont sizeascentdescent
IPAMinchoBOLD9.182
IPAMinchoBOLD10.392
IPAMinchoBOLD11.4102
IPAMinchoBOLD12.5112
IPAMinchoBOLD13.6122
IPAMinchoBOLD13.7122
IPAMinchoBOLD14.7132
IPAMinchoBOLD14.8132
IPAMinchoBOLD15.8142
IPAMinchoBOLD15.9142
IPAMinchoBOLD17152
IPAMinchoBOLD17.1153
IPAMinchoBOLD18.1163
IPAMinchoBOLD18.2163



**********************************
Oracle Corporation
Java HotSpot(TM) 64-Bit Server VM
1.7.0_17
**********************************
font namefont stylefont sizeascentdescent
IPAMinchoBOLD9.182
IPAMinchoBOLD10.392
IPAMinchoBOLD11.4102
IPAMinchoBOLD12.5112
IPAMinchoBOLD13.6122
IPAMinchoBOLD13.7122
IPAMinchoBOLD14.7132
IPAMinchoBOLD14.8132
IPAMinchoBOLD15.8142
IPAMinchoBOLD15.9142
IPAMinchoBOLD17152
IPAMinchoBOLD17.1153
IPAMinchoBOLD18.1163
IPAMinchoBOLD18.2163


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attached test code in  " Source code for an executable test case: "  below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
OpenJDK1.7 returns the same ascent and descent value with Returns of Oracle JDK1.6 and 1.7.
ACTUAL -
Returns of the getAscent() and the getDscent() are different between in OpenJDK1.7 and Sun JDK1.6/Oracle JDK 1.7.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import java.awt.*;

public class FontMetricsTest {

private static String[] fontNames = {  " IPAMincho " ,  " IPAGothic "  };
private static int[] fontStyles = { Font.PLAIN, Font.BOLD, Font.ITALIC };
private static String[] fontStyleNames = {  " PLAIN " ,  " BOLD " ,  " ITALIC "  };


/**
 * @param args
 */
public static void main(String[] args) {
System.out.println( " === FONT METRICS TEST === " );
System.out.println( " java vendor, " +System.getProperty( " java.vendor " ));
System.out.println( " java version, " +System.getProperty( " java.version " ));
System.out.println( " java vm name, " +System.getProperty( " java.vm.name " ));
System.out.println( " font name,font style,font size,ascent,descent " );
for (int n=0 ; n<fontNames.length ; n++) {
for (int s=0 ; s<fontStyles.length ; s++) {
Font baseFont = new Font(fontNames[n], fontStyles[s], 16);
if ((!baseFont.getFamily().equals(fontNames[n])) && (! baseFont.getFontName().equals(fontNames[n]))) {
System.out.println(fontNames[n]+ " ,not found " );
}
for (int i=5; i<=100 ; i++) {
for (int j=0 ; j<10 ; j++) {
float fontSize = (float)i + ((float)j)/10.0f;
Font dFont = baseFont.deriveFont(fontSize);
Component comp = new TestComp();
FontMetrics metrics = comp.getFontMetrics(dFont);
double ascent = metrics.getAscent();
double descent = metrics.getDescent();
System.out.println(fontNames[n]+ " , " +fontStyleNames[s]+ " , " +fontSize+ " , " +ascent+ " , " +descent);
}
}
}
}
}

private static class TestComp extends Component {

public TestComp(){
super();
}

}

}

---------- END SOURCE ----------
Comments
http://mail.openjdk.java.net/pipermail/2d-dev/2014-February/004188.html My customer encountered this issue. I think this issue is caused by Bug 1435 [1] and 1659 [2] in IcedTea. I read source code of "freetype-2.5.0-4.fc20" . Bold style should affect Font Glyph only. However, current implementation of OpenJDK affects Font Face. Thus value of Ascent/Descent is incorrect. OracleJDK seems to use sun.font.T2KFontScaler to calculate these values. So this issue occurs in OpenJDK only. I think we need to merge patches of Bug 1435 and 1659 in IcedTea to fix JDK-8017773 . Could you merge these patches ? [1] http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1435 [2] http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1659
05-02-2014