简体   繁体   English

如何为AWT / Swing应用程序进行字体平滑处理?

[英]How to do Font Smoothing for AWT/Swing Application?

I need to do font smoothing for a AWT application on Windows System. 我需要在Windows系统上为AWT应用程序进行字体平滑。 On doing googling I came to know that I can set following VM argument in Eclipse. 在谷歌搜索时,我发现我可以在Eclipse中设置以下VM参数。

-Dawt.useSystemAAFontSettings=gasp

But this is not yielding any positive results. 但这并没有产生任何积极的结果。 If anyone is having a better idea on how to achieve Font Smoothing, then kindly let me know. 如果有人对如何实现字体平滑有更好的了解,那么请告诉我。

EDIT After Answer By Andrew 安德鲁回答后编辑

I added the following snippet of code in paint method 我在paint方法中添加了以下代码片段

public class BottomSubmitButtons extends Canvas {

@Override
public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D)g;
    RenderingHints rh = new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
    g2.setRenderingHints(rh);
}
}

This seems to have improved the smoothing in one of the sub panel. 这似乎改善了其中一个子面板的平滑度。 But doing the same in other panel is not yielding any smoothing. 但是在其他面板中做同样的事情并没有产生任何平滑。 Also the TextField boxes are going invisible by default, though they becomes visible once I click in that area 默认情况下,TextField框也是不可见的,但是一旦我点击该区域,它们就会变得可见

Play with the values for RenderingHints.KEY_TEXT_LCD_CONTRAST . 使用RenderingHints.KEY_TEXT_LCD_CONTRAST的值进行播放。 When you find something that works, use that as the command line value. 当您找到有效的东西时,将其用作命令行值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM