views:

1744

answers:

2

Many Java Apps don't use anti-aliased fonts by default, despite the capability of Swing to provide them. How can you coerce an arbitrary java application to use AA fonts? (both for applications I'm running, and applications I'm developing)

+4  A: 

If you have access to the source, you can do this in the main method:

  // enable anti-aliased text:
  System.setProperty("awt.useSystemAAFontSettings","on");
  System.setProperty("swing.aatext", "true");

or, (and if you do not have access to the source, or if this is easier) you can simply pass the system properties above into the jvm by adding these options to the command line:

-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
rcreswick
A: 

hi rcreswick,

thanks for the info. I was wondering about this myself. I use SoapUI(www.eviware.com) and it does NOT, by default, use AA text. I added -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true to the batch file that launches it BUT that did NOT make a difference. Guess, I have to ask in their forum.

anjanb
it may be interpreting the arguments as pertaining to the application instead of the jvm -- you may need to dig into the bat file a bit deeper. (or it may not work for all apps... if so, please let me know / vote my answer down..)
rcreswick
I was able to get this to work by editing the .sh launch file so that the last line read: java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dsoapui.properties=soapui.properties -Dgroovy.source.encoding=iso-8859-1 -cp $SOAPUI_CLASSPATH com.eviware.soapui.SoapUIPro $*
rcreswick
I believe you could do the same with the soapui bat file by adding the -D.... params listed here to the JAVA_OPTS line, or just specifying JAVA_OPTS=-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true in the surrounding environment
rcreswick