Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java text-antialiasing: how to debug when not working?

I'm working on a fairly big Swing-based app (JPanels, JLabels, etc) and I have to find out why text-antialiasing (on JLabels etc) is not working.

As you may know, antialiasing normally works automagically (with Java 1.6 anyway), that is, when one creates a simple Swing-app (for example, just a JPanel with a JLabel on it) the text on the JLabel will be antialiased out of the box. No need for System.setProperty("awt.useSystemAAFontSettings","on") and/or System.setProperty("swing.aatext", "true").

But this app is different, it does not antialias out of the box, it does not antialias with System.setProperty("awt.useSystemAAFontSettings","on") and/or System.setProperty("swing.aatext", "true") in the main(String[] args), on also not with -Dawt.useSystemAAFontSettings=on and/or -Dswing.aatext=true as VM-arguments. I've tried these and other all suggestions I could find on this site and on internet, but to no avail: this app just never antialiases, whatever I do or don't.

I'm out of options now. So my questions are:

  • What steps can I take to find out why antialiasing is not working ?
  • What properties should I check ?
  • What code should I trace with the debugger ?
  • What circumstances could cause antialias not to work ?

All insights are welcome.

like image 890
Howard Avatar asked Apr 01 '11 12:04

Howard


2 Answers

Try the advice in System Properties for Java 2D™ Technology: awt.useSystemAAFontSettings.

like image 158
Andrew Thompson Avatar answered Oct 31 '22 17:10

Andrew Thompson


As of 1.6, it looks like swing.aatext is ignored. However, as noted by @Andrew, awt.useSystemAAFontSettings should work...

One of the things you might want to do is dump out the Map for the awt.font.desktophints desktop property just to see what, if anything, has been set.

like image 37
kschneid Avatar answered Oct 31 '22 18:10

kschneid