[英]How can I force Red Hat OpenJDK 8 to render fonts as clearly as AdoptOpenJDK and Oracle JDK on Windows?
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. 我们的用户在Windows桌面上运行Java GUI应用程序,我们正计划从Oracle Java 8切换到OpenJDK8。但是,我们发现使用Oracle和AdoptOpenJDK时,不同的OpenJDK构建在字体渲染质量方面不一致。相当,但Red Hat严重缺乏。
The following screenshot shows a simple Java AWT/Swing program on Windows on the three different JDKs: 以下屏幕快照显示了Windows上三个不同JDK上的简单Java AWT / Swing程序:
There's some problem with the rendering in the Red Hat JDK, because every character is distorted. Red Hat JDK中的渲染存在一些问题,因为每个字符都会变形。
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): 该程序只是显示带有命令行指定Dialog / bold / 12字体的Swing JLabel(每个JDK都将其映射到Windows OS Arial字体):
$ cat 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="): 下面的附加屏幕快照在此Windows系统上可用的3个Swing PLAF上显示相同的字体,并显示在Red Hat OpenJDK下的外观对于每个PLAF都是一致的(通过系统属性选项“ -Dswing.defaultlaf =”设置):
Does anyone know why the Red Hat OpenJDK build would render fonts in a way that's so different? 有谁知道为什么Red Hat OpenJDK构建会以如此不同的方式呈现字体? Is it possibly some additional JDK configuration or setup that the Red Hat OpenJDK might require? Red Hat OpenJDK可能需要其他JDK配置或设置吗?
Update - the workaround in alexkasko's answer (thank you!) of setting environment variable FREETYPE_PROPERTIES does correct the font issue, as of OpenJDK version 1.8.0_201-2-redhat-b09: 更新 -从OpenJDK版本1.8.0_201-2-redhat-b09开始,alexkasko的答案(设置环境变量FREETYPE_PROPERTIES)中的解决方法确实纠正了字体问题:
This is a regression in Red Hat build caused by the FreeType update to 2.8 . 这是由FreeType更新到2.8导致的Red Hat构建中的回归。 AdoptOpenJDK jdk8 build uses older FreeType 2.5.3 . AdoptOpenJDK jdk8构建使用较旧的FreeType 2.5.3 。 This is going to be fixed in Red Hat builds, meanwhile the old behaviour can be re-enabled using environment variable: 这将在Red Hat版本中修复,同时可以使用环境变量重新启用旧行为:
FREETYPE_PROPERTIES=truetype:interpreter-version=35
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.