-
Bug
-
Resolution: Won't Fix
-
P4
-
7u80, 8
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
Tested on a Linux system, Fedora Workstation 27 x64. The Cantarell font is from package abattis-cantarell-fonts-0.0.25-3.fc27.noarch.
A DESCRIPTION OF THE PROBLEM :
In JDK 8u172 for Linux x64, Swing text components cut off the bottom portion of the text on some TrueType and OpenType fonts. The problem does not appear in OpenJDK 8, JDK 9.0.4, or 10.0.1. A similar problem has been reported by others when running netbeans under various JDK 8 releases. The Cantarell font is strongly affected. A test program shows that affected fonts show a negative descent value. Examination of the font metrics in the OS/2, head, and hhea tables using otfinfo from the texlive-lcdftypetools shows affected fonts having a descent value more negative than -256, suggesting truncation to 8 bits somewhere in swing or awt. (TTF tables have negative values, Java inverts them). Some fonts like FreeMono work correctly.
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using attached source files fontbug/Main.java and fontbug/FontPanel.java, compile from the directory containing fontbug.
javac fontbug/*.java
Run the program using the 1.8.0_172 java.
java fontbug.Main Cantarell 36
The first parameter is the font name, the second the point size.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Positive font metric descent is listed, font renders properly.
This is a run using OpenJDK 1.8.0_171_b10
JLabel font java.awt.Font[family=Cantarell,name=Cantarell,style=plain,size=36]
FontMetrics ascent 35 descent 11 max ascent 35 max descent 11 height 46 leading 0
ACTUAL -
Font metric with negative descent is listed, and the text in the JLabel is clipped at the bottom.
JLabel font java.awt.Font[family=Cantarell,name=Cantarell,style=plain,size=36]
FontMetrics ascent 37 descent -11 max ascent 37 max descent -11 height 37 leading 11
---------- BEGIN SOURCE ----------
fontbug/Main.java
package fontbug;
import java.awt.Font;
import javax.swing.*;
public class Main implements Runnable {
Font font = null;
public Main(Font font) {
super();
this.font = font;
}
// Implement Runnable for Swing, build GUI here.
public void run() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Font Bug Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new FontPanel(font));
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
Font font = null;
try {
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
if (args.length > 1) {
int fontSize = Integer.parseInt(args[1]);
font = new Font(args[0], Font.PLAIN, fontSize);
} else {
System.out.println("Usage: java -jar fontbug.jar font-name point-size");
System.out.println("example: java -jar fontbug.jar Cantarell 36");
}
} catch (Exception e) {
System.out.println(e);
}
if (font == null)
System.out.println("Could not load font");
else {
javax.swing.SwingUtilities.invokeLater(new Main(font));
}
}
}
--------------------------
fontbug/FontPanel.java
package fontbug;
import javax.swing.*;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
// Panel containing a label with a quit button below it.
class FontPanel extends JPanel {
public FontPanel(Font font) {
super();
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
JLabel label = new JLabel("fgpqy");
label.setFont(font);
this.add(label);
FontMetrics fm = label.getFontMetrics(font);
System.out.println("JLabel font " + font.toString());
System.out.println("FontMetrics ascent " + fm.getAscent()
+ " descent " + fm.getDescent()
+ " max ascent " + fm.getMaxAscent()
+ " max descent " + fm.getMaxDescent()
+ " height " + fm.getHeight()
+ " leading " + fm.getLeading());
JButton quitButton = new JButton("quit fgpqy");
quitButton.setFont(font);
quitButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
this.add(quitButton);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Avoid using affected fonts. Cantarell seems to be the worst one.
FREQUENCY : always
Tested on a Linux system, Fedora Workstation 27 x64. The Cantarell font is from package abattis-cantarell-fonts-0.0.25-3.fc27.noarch.
A DESCRIPTION OF THE PROBLEM :
In JDK 8u172 for Linux x64, Swing text components cut off the bottom portion of the text on some TrueType and OpenType fonts. The problem does not appear in OpenJDK 8, JDK 9.0.4, or 10.0.1. A similar problem has been reported by others when running netbeans under various JDK 8 releases. The Cantarell font is strongly affected. A test program shows that affected fonts show a negative descent value. Examination of the font metrics in the OS/2, head, and hhea tables using otfinfo from the texlive-lcdftypetools shows affected fonts having a descent value more negative than -256, suggesting truncation to 8 bits somewhere in swing or awt. (TTF tables have negative values, Java inverts them). Some fonts like FreeMono work correctly.
REGRESSION : Last worked in version 8u172
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using attached source files fontbug/Main.java and fontbug/FontPanel.java, compile from the directory containing fontbug.
javac fontbug/*.java
Run the program using the 1.8.0_172 java.
java fontbug.Main Cantarell 36
The first parameter is the font name, the second the point size.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Positive font metric descent is listed, font renders properly.
This is a run using OpenJDK 1.8.0_171_b10
JLabel font java.awt.Font[family=Cantarell,name=Cantarell,style=plain,size=36]
FontMetrics ascent 35 descent 11 max ascent 35 max descent 11 height 46 leading 0
ACTUAL -
Font metric with negative descent is listed, and the text in the JLabel is clipped at the bottom.
JLabel font java.awt.Font[family=Cantarell,name=Cantarell,style=plain,size=36]
FontMetrics ascent 37 descent -11 max ascent 37 max descent -11 height 37 leading 11
---------- BEGIN SOURCE ----------
fontbug/Main.java
package fontbug;
import java.awt.Font;
import javax.swing.*;
public class Main implements Runnable {
Font font = null;
public Main(Font font) {
super();
this.font = font;
}
// Implement Runnable for Swing, build GUI here.
public void run() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Font Bug Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new FontPanel(font));
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
Font font = null;
try {
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
if (args.length > 1) {
int fontSize = Integer.parseInt(args[1]);
font = new Font(args[0], Font.PLAIN, fontSize);
} else {
System.out.println("Usage: java -jar fontbug.jar font-name point-size");
System.out.println("example: java -jar fontbug.jar Cantarell 36");
}
} catch (Exception e) {
System.out.println(e);
}
if (font == null)
System.out.println("Could not load font");
else {
javax.swing.SwingUtilities.invokeLater(new Main(font));
}
}
}
--------------------------
fontbug/FontPanel.java
package fontbug;
import javax.swing.*;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
// Panel containing a label with a quit button below it.
class FontPanel extends JPanel {
public FontPanel(Font font) {
super();
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
JLabel label = new JLabel("fgpqy");
label.setFont(font);
this.add(label);
FontMetrics fm = label.getFontMetrics(font);
System.out.println("JLabel font " + font.toString());
System.out.println("FontMetrics ascent " + fm.getAscent()
+ " descent " + fm.getDescent()
+ " max ascent " + fm.getMaxAscent()
+ " max descent " + fm.getMaxDescent()
+ " height " + fm.getHeight()
+ " leading " + fm.getLeading());
JButton quitButton = new JButton("quit fgpqy");
quitButton.setFont(font);
quitButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
this.add(quitButton);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Avoid using affected fonts. Cantarell seems to be the worst one.
FREQUENCY : always