Debian Bug report logs -
#657854
OpenJDK 6 and 7 returns incorrect TrueType font metrics
Reported by: Nobuhiro Ban <ban.nobuhiro@gmail.com>
Date: Sun, 29 Jan 2012 13:21:01 UTC
Severity: normal
Tags: patch
Found in version openjdk-7/7~b147-2.0-1
Fixed in version openjdk-7/7~u3-2.1.1-2
Done: Damien Raude-Morvan <drazzib@debian.org>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded
to debian-bugs-dist@lists.debian.org, OpenJDK Team <openjdk@lists.launchpad.net>:
Bug#657854; Package openjdk-7-jre.
(Sun, 29 Jan 2012 13:21:05 GMT) (full text, mbox, link).
Acknowledgement sent
to Nobuhiro Ban <ban.nobuhiro@gmail.com>:
New Bug report received and forwarded. Copy sent to OpenJDK Team <openjdk@lists.launchpad.net>.
(Sun, 29 Jan 2012 13:21:05 GMT) (full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: openjdk-7-jre
Version: 7~b147-2.0-1
Severity: normal
Dear Maintainer,
OpenJDK returns incorrect TrueType font height (greater than real value)
under some conditions, this makes JasperReports (Java reporting library)
not to work correctly on OpenJDK 6/7.
Problem
=======
On OpenJDK JRE and using some TrueType font, JasperReports does not
display text element which height is just the same as the font size
eg. { height="8", size="8", font="IPA mincho" }.
JasperReports checks the text size before drawing the text elements.
If (ascent + descent) of text is greater than the height of text
element, this text is not drawn.
In above case, Sun Java returns the same height (ascent + descent =
fontsize), but OpenJDK returns the text height greater than font size,
so not drawn.
Sample code (includes Japanese char)
===================================
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
public class JavaApplication1 {
public static void main(String[] args) throws Exception {
Font f = new Font("IPA明朝",Font.PLAIN, 8);
TextLayout layout = new TextLayout("IPA明朝", f,
new FontRenderContext(null, true, true));
System.out.println("Ascent: " + layout.getAscent());
System.out.println("Descent: " + layout.getDescent());
}
}
Result of this code
===================
Sun Java 6 (sun-java6-jre 6.26-0squeeze1)
> Ascent: 7.0390625
> Descent: 0.9609375
OpenJDK 6 (openjdk-6-jre 6b24~pre2-1)
> Ascent: 7.046875
> Descent: 0.96875
OpenJDK 7 (openjdk-7-jre 7~b147-2.0-1)
> Ascent: 7.046875
> Descent: 0.96875
Sun Java returns correct height, but OpenJDK returns greater value
than Sun's.
Analysis of Source code
=======================
In OpenJDK6/7 native method sun.font.FreetypeFontScaler.getFontMetricsNative():
jdk/src/share/native/sun/font/freetypeScaler.c
>JNIEXPORT jobject JNICALL
>Java_sun_font_FreetypeFontScaler_getFontMetricsNative(
> JNIEnv *env, jobject scaler, jobject font2D,
> jlong pScalerContext, jlong pScaler) {
(snip)
> /* ascent */
> ax = 0;
> ay = -(jfloat) FT26Dot6ToFloat(FT_MulFix(
> ((jlong) scalerInfo->face->ascender + bmodifier/2),
> (jlong) scalerInfo->face->size->metrics.y_scale));
> /* descent */
> dx = 0;
> dy = -(jfloat) FT26Dot6ToFloat(FT_MulFix(
> ((jlong) scalerInfo->face->descender + bmodifier/2),
> (jlong) scalerInfo->face->size->metrics.y_scale));
(snip)
> metrics = (*env)->NewObject(env,
> sunFontIDs.strikeMetricsClass,
> sunFontIDs.strikeMetricsCtr,
> ax, ay, dx, dy, bx, by, lx, ly, mx, my);
>
> return metrics;
>}
This code uses FT_MulFix to convert size. But FT_MulFix sometimes rounds
up and loses precision.
In FreeType2's FT_MulFix:
freetype-2.4.8/src/base/ftcalc.c
> c = (FT_Long)( ( (FT_Int64)a * b + 0x8000L ) >> 16 );
If both ascent and descent are rounded up, (ascent + descent) is greater
than original height.
In the sample case (IPA mincho font),
bmodifier = 0
scalerInfo->face->ascender = 1802L
scalerInfo->face->descender = -246L
scalerInfo->face->size->metrics.y_scale = 16384L
In this case, 1802 mod 4 = 2 and 246 mod 4 = 2, so both are rounded up.
This causes (ay + dy) > font-size.
(Note: (Sun) 1802.0/256.0 = 7.0390625, (OpenJDK) 1804.0/256.0 = 7.046875)
Suggested fix
=============
Fix to keep the precision in the font metrics conversion in
Java_sun_font_FreetypeFontScaler_getFontMetricsNative().
Version of packages
===================
OpenJDK:
see below.
JasperReports:
upstream 4.1.3 jar.
IPA TrueType fonts:
ii fonts-ipafont 00303-5
ii fonts-ipafont-gothic 00303-5
ii fonts-ipafont-mincho 00303-5
Reportbug output
================
-- System Information:
Debian Release: wheezy/sid
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.1.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages openjdk-7-jre depends on:
ii libaccess-bridge-java-jni 1.26.2-8
ii libasound2 1.0.24.1-4
ii libatk1.0-0 2.2.0-2
ii libc6 2.13-24
ii libcairo2 1.10.2-6.2
ii libcups2 1.5.0-13
ii libfontconfig1 2.8.0-3
ii libfreetype6 2.4.8-1
ii libgdk-pixbuf2.0-0 2.24.0-2
ii libgif4 4.1.6-9
ii libglib2.0-0 2.30.2-4
ii libgtk2.0-0 2.24.8-3
ii libjpeg8 8c-2
ii libpango1.0-0 1.29.4-2
ii libpng12-0 1.2.46-4
ii libpulse0 1.0-4
ii libx11-6 2:1.4.4-4
ii libxext6 2:1.3.0-3
ii libxi6 2:1.4.5-1
ii libxrender1 1:0.9.6-2
ii libxtst6 2:1.2.0-4
ii openjdk-7-jre-headless 7~b147-2.0-1
ii zlib1g 1:1.2.3.4.dfsg-3
Versions of packages openjdk-7-jre recommends:
ii ttf-dejavu-extra 2.33-2
Versions of packages openjdk-7-jre suggests:
pn icedtea6-plugin <none>
-- no debconf information
Information forwarded
to debian-bugs-dist@lists.debian.org, OpenJDK Team <openjdk@lists.launchpad.net>:
Bug#657854; Package openjdk-7-jre.
(Fri, 04 May 2012 04:39:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Nobuhiro Ban <ban.nobuhiro@gmail.com>:
Extra info received and forwarded to list. Copy sent to OpenJDK Team <openjdk@lists.launchpad.net>.
(Fri, 04 May 2012 04:39:03 GMT) (full text, mbox, link).
Message #10 received at 657854@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
clone 657854 -1
reassign 657854 openjdk-7-jre-headless
reassign -1 openjdk-6-jre-headless 6.26-0squeeze1
tags 657854 + patch
thanks
Hi,
I wrote patch for openjdk-7.
Regards,
Nobuhiro
[657854-openjdk7.patch (application/octet-stream, attachment)]
Bug 657854 cloned as bug 671443
Request was from Nobuhiro Ban <ban.nobuhiro@gmail.com>
to control@bugs.debian.org.
(Fri, 04 May 2012 04:39:04 GMT) (full text, mbox, link).
No longer marked as found in versions openjdk-7/7~b147-2.0-1.
Request was from Nobuhiro Ban <ban.nobuhiro@gmail.com>
to control@bugs.debian.org.
(Fri, 04 May 2012 04:39:06 GMT) (full text, mbox, link).
Added tag(s) patch.
Request was from Nobuhiro Ban <ban.nobuhiro@gmail.com>
to control@bugs.debian.org.
(Fri, 04 May 2012 04:39:09 GMT) (full text, mbox, link).
Marked as found in versions openjdk-7/7~b147-2.0-1.
Request was from Nobuhiro Ban <ban.nobuhiro@gmail.com>
to control@bugs.debian.org.
(Fri, 04 May 2012 04:48:03 GMT) (full text, mbox, link).
Reply sent
to Damien Raude-Morvan <drazzib@debian.org>:
You have taken responsibility.
(Mon, 23 Jul 2012 21:21:07 GMT) (full text, mbox, link).
Notification sent
to Nobuhiro Ban <ban.nobuhiro@gmail.com>:
Bug acknowledged by developer.
(Mon, 23 Jul 2012 21:21:07 GMT) (full text, mbox, link).
Message #25 received at 657854-close@bugs.debian.org (full text, mbox, reply):
Source: openjdk-7
Source-Version: 7~u3-2.1.1-2
We believe that the bug you reported is fixed in the latest version of
openjdk-7, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 657854@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Damien Raude-Morvan <drazzib@debian.org> (supplier of updated openjdk-7 package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Format: 1.8
Date: Sat, 30 Jun 2012 18:17:51 +0200
Source: openjdk-7
Binary: openjdk-7-jdk openjdk-7-jre-headless openjdk-7-jre openjdk-7-jre-lib openjdk-7-demo openjdk-7-source openjdk-7-doc openjdk-7-dbg icedtea-7-jre-cacao icedtea-7-jre-jamvm openjdk-7-jre-zero
Architecture: source amd64 all
Version: 7~u3-2.1.1-2
Distribution: sid
Urgency: low
Maintainer: OpenJDK Team <openjdk@lists.launchpad.net>
Changed-By: Damien Raude-Morvan <drazzib@debian.org>
Description:
icedtea-7-jre-cacao - Alternative JVM for OpenJDK, using Cacao
icedtea-7-jre-jamvm - Alternative JVM for OpenJDK, using JamVM
openjdk-7-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-7-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-7-doc - OpenJDK Development Kit (JDK) documentation
openjdk-7-jdk - OpenJDK Development Kit (JDK)
openjdk-7-jre - OpenJDK Java runtime, using ${vm:Name}
openjdk-7-jre-headless - OpenJDK Java runtime, using ${vm:Name} (headless)
openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries)
openjdk-7-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-7-source - OpenJDK Development Kit (JDK) source files
Closes: 657854 678228 679036 679292 679465 680284
Changes:
openjdk-7 (7~u3-2.1.1-2) unstable; urgency=low
.
* d/rules: On Debian Wheezy/Sid bump Build-Depends on libnss3-dev
(>= 2:3.13.4) and Depends on libnss3 (>= 2:3.13.4) (ie. with epoch).
(Closes: #679465).
* d/control: Suggests icedtea-7-plugin instead of icedtea6-plugin
(Closes: #680284).
* d/patches/7130140-MouseEvent-systemout.diff: Remove "MEvent. CASE!" from
console output. (Closes: #679036).
* Disable -O3 compile: cause wrong Math.* computations.
(Closes: #679292 and Closes: #678228).
* debian/patches/FreetypeFontScaler_getFontMetricsNative.diff:
Fix "OpenJDK returns the text height greater than font size".
(Closes: #657854)
Checksums-Sha1:
e50db097f351d5aef6ff43360a354246560a57f8 3552 openjdk-7_7~u3-2.1.1-2.dsc
ec2d80e48fd4cfb3720631539b41701ff9e54d67 197686 openjdk-7_7~u3-2.1.1-2.diff.gz
ba7a332ea3044463223720eec651e838fe9e3849 11551262 openjdk-7-jdk_7~u3-2.1.1-2_amd64.deb
cb7c04d513e726db82c9c286b92cb702d14d12a8 28145228 openjdk-7-jre-headless_7~u3-2.1.1-2_amd64.deb
8ed39a98b3de9fb350b1ffe6b09c313b0826ecf0 228544 openjdk-7-jre_7~u3-2.1.1-2_amd64.deb
8f9d1ad7e8dd77914210d2e7bed514776fe32639 2488642 openjdk-7-demo_7~u3-2.1.1-2_amd64.deb
72f6e37058dc3d9b04440027d9363e1368802275 153889108 openjdk-7-dbg_7~u3-2.1.1-2_amd64.deb
4dfa9db4db7bd4dae3fc84d232802af286d8ea5c 894276 icedtea-7-jre-cacao_7~u3-2.1.1-2_amd64.deb
233f3bd75dc2183c6309c4e903e1514368f21e3b 466388 icedtea-7-jre-jamvm_7~u3-2.1.1-2_amd64.deb
588c2c6c22799c49815e4409ffc25df5068b7021 2381042 openjdk-7-jre-zero_7~u3-2.1.1-2_amd64.deb
2d57a09796ee1f9407bd6bdd4c932a1f496c48fa 5224258 openjdk-7-jre-lib_7~u3-2.1.1-2_all.deb
f4405143340bea5ec3b28ac12eb78d1d24c26ec9 41355262 openjdk-7-source_7~u3-2.1.1-2_all.deb
2a2ff875194784efe2f763bdc598b0ffb1437dff 22082738 openjdk-7-doc_7~u3-2.1.1-2_all.deb
Checksums-Sha256:
d454a385f7e35a41d1a92b8bb19fc5151aca151957e18b786006a32d595bb5c0 3552 openjdk-7_7~u3-2.1.1-2.dsc
c34b122e78c09e8860378517eec10954c14011a8f6b42bf1531aae52931cd234 197686 openjdk-7_7~u3-2.1.1-2.diff.gz
e1b8e81e5531bb534f94cbb6a17872cc89626198c0e80e6e3aaafdce37966f40 11551262 openjdk-7-jdk_7~u3-2.1.1-2_amd64.deb
3ce30ad3ad705a70d4fc6df305d1927ac24987368d6ca914e1830393232e9741 28145228 openjdk-7-jre-headless_7~u3-2.1.1-2_amd64.deb
459111ac93e9558a03d899debc87ab43cea382a1dab0e98a306b93c9ff8bf90e 228544 openjdk-7-jre_7~u3-2.1.1-2_amd64.deb
08f428542d78fd6c1089faa2afd68d35c0226f683d12dfd58d18e6e4b5ed383d 2488642 openjdk-7-demo_7~u3-2.1.1-2_amd64.deb
330a42654b9107a790666dfa0137245c7c676da243656570a3fe382d240a7058 153889108 openjdk-7-dbg_7~u3-2.1.1-2_amd64.deb
984cc7530c54d66f175b376d979190f6ad33da87b1f2eed2be059004d7a2c4e8 894276 icedtea-7-jre-cacao_7~u3-2.1.1-2_amd64.deb
2dd45416082489feb8d65740754004c2f0dded34b5dd2c640688f341b46dd9e9 466388 icedtea-7-jre-jamvm_7~u3-2.1.1-2_amd64.deb
b319dc72782a13b020c26bdd313ff08eb543efed216aef81cd7d2b036fddb327 2381042 openjdk-7-jre-zero_7~u3-2.1.1-2_amd64.deb
8ae7777cbe36e24b706ff3ffd52b82d3dd82918d76df530aa36f4d0decef99b1 5224258 openjdk-7-jre-lib_7~u3-2.1.1-2_all.deb
5dcd4dacc1e2482e1d20c4d65e3b50fa70a67ecffd2f126d4925468bdff9de79 41355262 openjdk-7-source_7~u3-2.1.1-2_all.deb
8bd32128fac408bb9afea5b814539bb119469e05b3e4490ad70109205474fa5e 22082738 openjdk-7-doc_7~u3-2.1.1-2_all.deb
Files:
19100377ac07aa64d964627a2dd6f9b3 3552 java optional openjdk-7_7~u3-2.1.1-2.dsc
e96607a8407f96af7c65dd99fd551f1d 197686 java optional openjdk-7_7~u3-2.1.1-2.diff.gz
b93fc43250ae20529b4d8f0f0042cac9 11551262 java optional openjdk-7-jdk_7~u3-2.1.1-2_amd64.deb
bd2adb9d3856c22bf4496115f37caf5f 28145228 java optional openjdk-7-jre-headless_7~u3-2.1.1-2_amd64.deb
6aa88bb38849eeb4be5c8da78e0c4481 228544 java optional openjdk-7-jre_7~u3-2.1.1-2_amd64.deb
631c277557912935297c1e306c7a93cd 2488642 java extra openjdk-7-demo_7~u3-2.1.1-2_amd64.deb
da43cb35de7d50bb048a0e1eccaf2610 153889108 debug extra openjdk-7-dbg_7~u3-2.1.1-2_amd64.deb
81b51efb114d28ca2a887c1c76d4bf84 894276 java extra icedtea-7-jre-cacao_7~u3-2.1.1-2_amd64.deb
3b4c937737216055ff765696bebea4dd 466388 java extra icedtea-7-jre-jamvm_7~u3-2.1.1-2_amd64.deb
fdf76af5a7555017f865e0d774a31265 2381042 java extra openjdk-7-jre-zero_7~u3-2.1.1-2_amd64.deb
26fe42b4afdae5e4ff10f16ade368b8d 5224258 java optional openjdk-7-jre-lib_7~u3-2.1.1-2_all.deb
254678318f5abe7a2321df085e44e3bf 41355262 java extra openjdk-7-source_7~u3-2.1.1-2_all.deb
603b0ec349beb7a41ff6c0f8158b5852 22082738 doc extra openjdk-7-doc_7~u3-2.1.1-2_all.deb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQIcBAEBCAAGBQJQDbBGAAoJEHXiDM0z50n8VdQQAJnqoYHm3DTqpITlp2pe+u71
drSN57dsYItl/9pScu9UaXJMVuazKlQXITW2GkyMa8oHyBDGUhW0yR9qs8Rrd+4b
uKbEUH/aNX+EnRXzhuLv9281V6o9YLnellIMyrb/vedGfBP9jlbDxzfklIMiDIGz
mlcggSd3rfnGaeumNAQ8n98p3aLlhHyvbwV+BxLobSyn0rUzue1baHldMfAeGJ1Q
uFlIVmyXvSQ8Enl5S2zCxUZsT3BfHPrpxFZ2uRJnDJBqTpogljMAV1b701LIT9cx
pSDCnOzuq2E25YEH0uCv4TVx9yDFIFRFis4TJgDrnuLnehp4zG+IyE0a4bhEKHUz
lfi6kl6oDluWS1Wop0e9O3n3v3q7PWbqgju9nS/9E+qSppLQsqbJO6qfHghp5CFx
rj7YUyRlBEttTIPccEQ+r0t1vMTg/dIgGQRSTzmXCJZDyxMIRGHhS276mUfrmz05
9jHMs1pljj1U8ChmsRtJwfxrTTjX+pvHLM70biKNLbjxkXF3KkgJmWTzKlCUzEtp
C1cZYJ3xKnIKm5zWC3QjxNUZ257hbvGk9ewBaaax92MVbosXXbSiZ17Iq1s77pk+
7glg+bMDnXKG3PY7oLnre/Hj+dfROYyZR0ytNU3RKrnl4GHWmexcZUL0+mRt13Is
4Ju6IWlSRerKcNJaHokv
=PBvB
-----END PGP SIGNATURE-----
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Thu, 23 Aug 2012 07:29:16 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Fri Nov 2 22:01:51 2018;
Machine Name:
buxtehude
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.