Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do Font Smoothing for AWT/Swing Application?

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

like image 694
tiger Avatar asked Sep 29 '11 07:09

tiger


1 Answers

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

like image 103
Andrew Thompson Avatar answered Nov 01 '22 06:11

Andrew Thompson