-
Bug
-
Resolution: Unresolved
-
P3
-
11, 17, 23, 24
ADDITIONAL SYSTEM INFORMATION :
Java 23 early access build 31 on Windows 10
A DESCRIPTION OF THE PROBLEM :
This is a bug introduced whenJDK-8214481 was fixed. That change was intended to disable font hinting when the user combines RenderingHints.VALUE_FRACTIONALMETRICS_ON and RenderingHints.VALUE_TEXT_ANTIALIAS_ON. However, there is another anti-aliasing setting, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP, which is intended to enable and disable anti-aliasing according to the font's "gasp" table. When this AA GASP rendering hint is used, and the system determines from the font that AA should be enabled, Java incorrectly assumes that the AA ON hint was used, and disables font hinting. Font hinting should remain enabled if anti-aliasing is enabled via the AA GASP hint.
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test file (see included JavaDoc, uses Windows system fonts).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
See https://imgur.com/a/qkGG46p for JDK 11.0.7 output (this is the last correct version). Hinting is being applied in column 3 (e.g. the Arial letter "i" in "size" at font size 22 is crisp, Palatino size 9+ lines are crisper and bolder than the smaller sizes).
ACTUAL -
See https://imgur.com/a/z1OUFAH for JDK 23 early access output. Hinting is no longer being applied in column 3 (e.g. the Arial letter "i" in "size" at font size 22 is blurrier than before, Palatino size 9+ lines are not crisper and bolder than the smaller sizes). The results on JDK 11.0.8 are the same.
---------- BEGIN SOURCE ----------
import static java.awt.RenderingHints.KEY_FRACTIONALMETRICS;
import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_GASP;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
/**
* <p>Arial contains the following "gasp" table entries (on Windows 10):
* <ul>
* <li>Range 1: <= 8 PPEM: anti-alias only</li>
* <li>Range 2: <= 17 PPEM: grid fit only</li>
* <li>Range 3: <= 65,535 PPEM: anti-alias and grid fit</li>
* </ul>
*
* <p>Palatino Linotype Bold contains the following "gasp" table entries (on Windows 10):
* <ul>
* <li>Range 1: <= 8 PPEM: anti-alias only</li>
* <li>Range 2: <= 65,535 PPEM: anti-alias and grid fit</li>
* </ul>
*
* <p>The change forJDK-8214481 should have applied to AA ON only, not to AA GASP.
* Thus, column 3 should be the same for JDK 11.0.7 and JDK 11.0.8. Instead, clear
* indications can be seen that hinting is no longer being applied in column 3,
* when it should be: the Arial letter "i" in "size" at font size 22 is blurrier
* than it was previously, and Palatino size 9+ lines are no longer noticeably
* bolder / crisper.
*
* @see https://bugs.openjdk.org/browse/JDK-8214481
* @see https://bugs.openjdk.org/browse/JDK-8242285
*/
public class AntialiasingGaspTest extends Component {
private static final long serialVersionUID = 6976569579551199526L;
public static void main(String[] args) {
String version = System.getProperty("java.version", "???");
JFrame frame = new JFrame("Antialiasing GASP Test on Java " + version);
frame.add(new AntialiasingGaspTest());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(1100, 750);
}
@Override
public void paint(Graphics g) {
Font arial = new Font("Arial", Font.PLAIN, 14);
Font palatino = new Font("Palatino Linotype", Font.BOLD, 14);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALMETRICS_ON);
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setColor(Color.BLACK);
drawColumn("ARIAL, FM ON, AA OFF", g2d, arial, 20, 20, VALUE_TEXT_ANTIALIAS_OFF);
drawColumn("ARIAL, FM ON, AA ON", g2d, arial, 370, 20, VALUE_TEXT_ANTIALIAS_ON);
drawColumn("ARIAL, FM ON, AA GASP", g2d, arial, 720, 20, VALUE_TEXT_ANTIALIAS_GASP);
drawColumn("PALATINO, FM ON, AA OFF", g2d, palatino, 20, 370, VALUE_TEXT_ANTIALIAS_OFF);
drawColumn("PALATINO, FM ON, AA ON", g2d, palatino, 370, 370, VALUE_TEXT_ANTIALIAS_ON);
drawColumn("PALATINO, FM ON, AA GASP", g2d, palatino, 720, 370, VALUE_TEXT_ANTIALIAS_GASP);
}
private static void drawColumn(String title, Graphics2D g2d, Font baseFont, int x, int y, Object aaHint) {
g2d.setRenderingHint(KEY_TEXT_ANTIALIASING, aaHint);
g2d.setFont(baseFont);
g2d.drawString(title, x, y);
y += g2d.getFontMetrics().getHeight();
for (int i = 1; i <= 22; i++) {
Font scaled = baseFont.deriveFont((float) i);
g2d.setFont(scaled);
g2d.drawString("This is a test at size " + i, x, y);
y += g2d.getFontMetrics().getHeight();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Java 23 early access build 31 on Windows 10
A DESCRIPTION OF THE PROBLEM :
This is a bug introduced when
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test file (see included JavaDoc, uses Windows system fonts).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
See https://imgur.com/a/qkGG46p for JDK 11.0.7 output (this is the last correct version). Hinting is being applied in column 3 (e.g. the Arial letter "i" in "size" at font size 22 is crisp, Palatino size 9+ lines are crisper and bolder than the smaller sizes).
ACTUAL -
See https://imgur.com/a/z1OUFAH for JDK 23 early access output. Hinting is no longer being applied in column 3 (e.g. the Arial letter "i" in "size" at font size 22 is blurrier than before, Palatino size 9+ lines are not crisper and bolder than the smaller sizes). The results on JDK 11.0.8 are the same.
---------- BEGIN SOURCE ----------
import static java.awt.RenderingHints.KEY_FRACTIONALMETRICS;
import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_GASP;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
/**
* <p>Arial contains the following "gasp" table entries (on Windows 10):
* <ul>
* <li>Range 1: <= 8 PPEM: anti-alias only</li>
* <li>Range 2: <= 17 PPEM: grid fit only</li>
* <li>Range 3: <= 65,535 PPEM: anti-alias and grid fit</li>
* </ul>
*
* <p>Palatino Linotype Bold contains the following "gasp" table entries (on Windows 10):
* <ul>
* <li>Range 1: <= 8 PPEM: anti-alias only</li>
* <li>Range 2: <= 65,535 PPEM: anti-alias and grid fit</li>
* </ul>
*
* <p>The change for
* Thus, column 3 should be the same for JDK 11.0.7 and JDK 11.0.8. Instead, clear
* indications can be seen that hinting is no longer being applied in column 3,
* when it should be: the Arial letter "i" in "size" at font size 22 is blurrier
* than it was previously, and Palatino size 9+ lines are no longer noticeably
* bolder / crisper.
*
* @see https://bugs.openjdk.org/browse/JDK-8214481
* @see https://bugs.openjdk.org/browse/JDK-8242285
*/
public class AntialiasingGaspTest extends Component {
private static final long serialVersionUID = 6976569579551199526L;
public static void main(String[] args) {
String version = System.getProperty("java.version", "???");
JFrame frame = new JFrame("Antialiasing GASP Test on Java " + version);
frame.add(new AntialiasingGaspTest());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(1100, 750);
}
@Override
public void paint(Graphics g) {
Font arial = new Font("Arial", Font.PLAIN, 14);
Font palatino = new Font("Palatino Linotype", Font.BOLD, 14);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALMETRICS_ON);
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setColor(Color.BLACK);
drawColumn("ARIAL, FM ON, AA OFF", g2d, arial, 20, 20, VALUE_TEXT_ANTIALIAS_OFF);
drawColumn("ARIAL, FM ON, AA ON", g2d, arial, 370, 20, VALUE_TEXT_ANTIALIAS_ON);
drawColumn("ARIAL, FM ON, AA GASP", g2d, arial, 720, 20, VALUE_TEXT_ANTIALIAS_GASP);
drawColumn("PALATINO, FM ON, AA OFF", g2d, palatino, 20, 370, VALUE_TEXT_ANTIALIAS_OFF);
drawColumn("PALATINO, FM ON, AA ON", g2d, palatino, 370, 370, VALUE_TEXT_ANTIALIAS_ON);
drawColumn("PALATINO, FM ON, AA GASP", g2d, palatino, 720, 370, VALUE_TEXT_ANTIALIAS_GASP);
}
private static void drawColumn(String title, Graphics2D g2d, Font baseFont, int x, int y, Object aaHint) {
g2d.setRenderingHint(KEY_TEXT_ANTIALIASING, aaHint);
g2d.setFont(baseFont);
g2d.drawString(title, x, y);
y += g2d.getFontMetrics().getHeight();
for (int i = 1; i <= 22; i++) {
Font scaled = baseFont.deriveFont((float) i);
g2d.setFont(scaled);
g2d.drawString("This is a test at size " + i, x, y);
y += g2d.getFontMetrics().getHeight();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8214481 freetype path does not disable TrueType hinting with AA+FM hints
- Resolved