I upgraded from Oracle JDK11 to Oracle JDK 12 and 14 and noticed that the later versions (12 and 14) seem to have a problem rendering the font "MS Reference Sans Serif". Anyone know why and how to fix? I suspect it could be related to the specific font. Maybe they dropped TrueType, FreeType or whatever render they use support for it in JDK 12. I don't see the same issue with other fonts. I guess I could simply change the font, but I like this particular font and would like to get it working if possible.
Oracle JDK 11:
Oracle JDK 14:
Code:
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class JavaFontTest extends JPanel {
public JavaFontTest() {
setBackground(Color.blue);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.RED);
g.setFont(new Font("MS Reference Sans Serif", Font.BOLD, 12));
g.drawString("The Quick Brown Fox", 0, 30);
g.drawString("Jumped over the Well", 0, 60);
}
public static void main(String[] args) {
JFrame jf = new JFrame();
jf.getContentPane().setLayout(new BoxLayout(jf.getContentPane(), BoxLayout.Y_AXIS));
jf.setExtendedState(Frame.MAXIMIZED_BOTH);
jf.add(new JavaFontTest());
jf.pack();
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}