如何在JavaFX字体中强制使用抗锯齿? [英] How to force anti-aliasing in JavaFX fonts?

查看:686
本文介绍了如何在JavaFX字体中强制使用抗锯齿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在测试我的JavaFX 8应用程序的GUI时,我注意到有些标签没有显示反锯齿文本。经过一番Google搜索和苦苦挣扎之后,我发现了一件非常烦人的事情。反锯齿仅适用于字体大于80像素的标签。下面是一个比较JavaFX和Swing应用程序与应用AA的示例: =enter image description here>



示例代码: https://gist.github.com/anonymous/be60bb89181376ff12aa



有没有办法强制所有字体大小的AA?
这是否也发生在你身上呢?我在 JavaFX Jira 上搜索了一个类似的错误,但是到目前为止没有人抱怨这个问题。也许我应该为此打开一个?



有些信息可能有帮助:

  Java™SE运行时环境(build 1.8.0-b132)
Java HotSpot™64位服务器虚拟机(版本25.0-b70,混合模式)
Windows 8.1 64位[版本6.3.9600]


解决方案

默认情况下,JavaFX 8使用modena.css来设置LCD抗锯齿,在某些情况下,似乎并不平滑字体。当字体大小大于80时,AA技术更改为灰度AA(出于性能考虑)。所以,为了在任何尺寸上实现平滑的边缘,应该使用灰度级AA。



这可以通过CSS完成:

  .text {
-fx-font-smoothing-type:grey;

或者通过系统参数:

  -Dprism.lcdtext = false 

系统属性:

  System.setProperty(prism.lcdtext,false); 

感谢所有回覆吉拉


While testing the GUI of my JavaFX 8 application, I noticed that some labels are not displaying anti-aliased text. After some googling and struggling, I found out a very annoying thing that is happening. The anti-aliasing is being applied only on labels which font size is greater than 80px. Here is an example comparing JavaFX and Swing applications with AA applied:

Sample code: https://gist.github.com/anonymous/be60bb89181376ff12aa

Is there a way to force the AA in all font sizes? Does this happen to you too? I searched for a similar bug on JavaFX Jira, but nobody is complaining about that so far. Maybe I should open one for this?

Some info that may help:

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
Windows 8.1 64 bits [Version 6.3.9600]

解决方案

By default, JavaFX 8 uses modena.css to set the LCD anti aliasing, which doesn't seem to smooth fonts in some cases. When the font size is greater than 80, the AA technique changes to grey scale AA (for performance concerns). So, to achieve smooth edges at any size, grey scale AA should be used instead.

This can be done by CSS:

.text{
    -fx-font-smoothing-type: gray;
}

Or through system arguments:

-Dprism.lcdtext=false

Or setting system properties:

System.setProperty("prism.lcdtext", "false");

Thanks everybody who replied on Jira!

这篇关于如何在JavaFX字体中强制使用抗锯齿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆