This content has been marked as final. Show 3 replies
First, I'm not an expert at all on font rendering.
1) the jvm property setting -Dawt.useSystemAAFontSettings=lcd suggests only an indication that an lcd screen is used. It does not imply any of the rendering hint values explicitly.
2) A search through the core java sources for various text antialiasing hints only produces some hits in FontRenderContext. For LCD_HRGB I cannot find any hit. That suggests that it is not queried at all. (at least not in the sources delivered with the JDK)
3) A Google revealed more people having trouble with these text antialiasing hints. So apparently you are not the only one :-)
thanks a lot for your reply and sorry for my late answer.
I still do not understand why setting the hint on the Graphics object does not work for a JLabel. Now I just set the JVM parameter "awt.useSystemAAFontSettings=lcd" from within my code when the application starts via "System.setProperty", and it works for me under Windows XP.
In Java 6, from my investigations, Swing components automatically detect the system settings and apply LCD antialiasing when drawing text. However:
There is a bug in Java2D that defeats LCD antialiasing: if the Graphics2D ANTIALIASING hint is ON, then the TEXT_ANTIALIASING_LCD hint is ignored, and you get standard greyscale text antialiasing. It appears this may be fixed in Java 7. In the meantime, set ANTIALIASING to OFF in the graphics context.
You shouldn't have to mess with the TEXT_ANTIALIASING hint, as it is set when the text is drawn, deep down in SwingUtilities2.drawString(). You would only need to manipulate this hint if you are drawing text yourself using Java2D primitives.
Note that on Windows XP, the system setting that drives the automatic behavior is in Control Panel / Display / Appearance / Effects / 'Use the following method to smooth edges of screen fonts'. This must be set to ClearType to enable automatic LCD AA in Swing. The -Dawt.useSystemAAFontSettings=lcd setting overrides the detection of system settings. But due to the bug in Java2D, it means that you may sometimes see subpixel antialiasing and sometimes not, depending on the current state of the antialias hint in the graphics context.