disabling anti-aliased fonts in netbeans on osx 6

Posted by peter on December 08, 2009

it’s harder than you might think, and i haven’t found a perfect solution, but i’m pretty close.

in eclipse, likely because of swt’s use of jni to use os-native forms, you can simply set an application-specific anti-aliasing threshold for the application:

defaults write org.eclipse.eclipse AppleAntiAliasingThreshold 20

and this more or less works (thanks to tim for pointing this out here), but with netbeans, no joy.

our buddy netbeans uses swing, which doesn’t look at application property plists. since apple rolls their own ui elements for swing/awt on osx (best of my knowledge), we’re in strange waters, as well. there’s a hackier way to do this, documented here on the netbeans forums for netbeans 6.5, and involves appending the following flags to netbeans_default_options in the netbeans.conf file inside the netbeans application bundle- that’s .../NetBeans\ 6.7.1.app/Contents/Resources/NetBeans/etc/netbeans.conf

-J-Dswing.aatext=false -Dawt.useSystemAAFontSettings=false

and this works fine and dandy, if you’re using the standard “Monospace” font.

netbeans 3.7.1 using monospace on 10.6

However, this fails miserably if you’re using something else, like profont or (my pick) pragmata. in that case, at least if you’re on 10.6, you get a mess that looks like this:


note that fonts are being drawn on top of each other. selecting text and moving the cursor around makes for an even bigger mess.

i’ve noticed that apple’s release notes contain a note saying that the swing.aatext system property was ignored in apple’s first release of java6 on osx, so my guess is that either they didn’t get it quite right, or that netbeans is getting rendered glyph sizes wrong. my money is on this being an apple screwup, as it works great with the default monospaced font, but this is also me talking out my ass as i haven’t bothered even looking at how this works in another swing application.

this is the point where i give up and admit that i’m spending more time than i should on getting my special font working. if anyone else has any clues past this point, i’m all ears!