Our users run our Java GUI app on their Windows desktops, and we're planning a switch from Oracle Java 8 to OpenJDK 8. But we've found that different OpenJDK builds are inconsistent in the quality of the font rendering, with Oracle and AdoptOpenJDK being equivalent but Red Hat severely lacking.
The following screenshot shows a simple Java AWT/Swing program on Windows on the three different JDKs:
There's some problem with the rendering in the Red Hat JDK, because every character is distorted.
The program is just displaying a Swing JLabel with the command-line-specified Dialog/bold/12 font (which each JDK maps to the Windows OS Arial font):
// fontname.groovy
import javax.swing.*
import java.awt.Font
import sun.font.*
styles=[bold:Font.BOLD,italic:Font.ITALIC,plain:Font.PLAIN]
SwingUtilities.invokeLater({
l = new JLabel("${args}: ${System.getProperty('java.runtime.name')} ${System.getProperty('java.runtime.version')}")
l.setFont(new Font(args[0],styles[args[1]],Integer.valueOf(args[2])))
f = new JFrame()
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
f.getContentPane().setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
f.getContentPane().add(l)
f.pack()
f.setVisible(true)
logicalFont = l.getGraphics().getFont()
print(logicalFont)
physicalFont = FontManagerFactory.getInstance().findFont2D( logicalFont.getName(), 0, FontManager.NO_FALLBACK )
print(physicalFont)
})
The additional screenshot below shows the same font on 3 Swing PLAFs available on this Windows system and shows that the appearance under Red Hat OpenJDK is consistent for each PLAF (set via system property option -Dswing.defaultlaf=
):
Does anyone know why the Red Hat OpenJDK build would render fonts in a way that's so different? Is it possibly some additional JDK configuration or setup that the Red Hat OpenJDK might require?
This is a regression in the Red Hat build caused by the FreeType update to 2.8. The AdoptOpenJDK Java 8 build uses the older FreeType 2.5.3.
Until Red Hat fixes it, the old behaviour can be re-enabled by setting the interpretor-version
property of the TrueType driver to version 35, which can be done with an environment variable:
FREETYPE_PROPERTIES="truetype:interpreter-version=35"