How to do Font Smoothing for AWT/Swing Application?

故事扮演 提交于 2020-01-03 10:31:59

问题


I need to do font smoothing for a AWT application on Windows System. On doing googling I came to know that I can set following VM argument in Eclipse.

-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

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


回答1:


Play with the values for RenderingHints.KEY_TEXT_LCD_CONTRAST. When you find something that works, use that as the command line value.



来源:https://stackoverflow.com/questions/7593944/how-to-do-font-smoothing-for-awt-swing-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!