Source: openjdk-8 Severity: normal Tags: patch Dear Maintainer,
Problem ======= java.awt.Font#deriveFont(int style) tries to create new Font instance that has the same font size. But it uses rounded font size wrongly. So derived font has different font size. (openjdk-7 has a same problem.) Sample code =========== import java.awt.Font; public class DeriveFontProblem { public static void main(String[] args) { Font fontBase = new Font("Helvetica", Font.PLAIN, 1); Font font105 = fontBase.deriveFont(10.5f); System.out.println("font105 : size=" + font105.getSize2D()); Font font105Plain = font105.deriveFont(Font.PLAIN); System.out.println("font105Plain: size=" + font105Plain.getSize2D()); } } Result of this code =================== Actual >font105 : size=10.5 >font105Plain: size=11.0 Expected >font105 : size=10.5 >font105Plain: size=10.5 Suggested fix ============= Font#deriveFont(int style) should use (float) "pointSize", not (int) "size". Here is a patch to fix: --- java/awt/Font.java.orig 2016-08-12 01:03:10.703646834 +0900 +++ java/awt/Font.java 2016-08-12 01:02:43.091646225 +0900 @@ -1933,7 +1933,7 @@ */ public Font deriveFont(int style){ if (values == null) { - return new Font(name, style, size, createdFont, font2DHandle); + return new Font(name, style, pointSize, createdFont, font2DHandle); } AttributeValues newValues = getAttributeValues().clone(); int oldStyle = (this.style != style) ? this.style : -1; Reportbug output ================ -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (990, 'testing'), (500, 'oldstable-updates'), (500, 'unstable'), (500, 'oldstable') Architecture: amd64 (x86_64) Kernel: Linux 3.14-2-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 Init: unable to detect