Java 6, font anti-aliasing, and brain-dead API...

One of the big features that Java 6 added was the ability to use subpixel anti-aliasing when rendering fonts. This greatly improves the way fonts look on LCD screens, making it far more readable. By default, Swing now uses these AA settings.

Unfortunately, for what I can only imagine must be backwards compatibility reasons, text rendered by user components in Java still uses no font anti-aliasing. (Period.)

Fortunately there's API that allows you to enable subpixel rendering.

Unfortunately it's a little, uh, too specific. You get four options for subpixel rendering, which are, in alphabetical order: HBGR, HRGB, VBGR, VRGB. These correspond to four different ways an LCD screen can stripe red, green, and blue pixels.

See if you can guess where this is going.

There's absolutely no way to detect what striping mode the monitor uses, of course!

This isn't too surprising, since as far as I know there's no spec to allow a computer to ask a monitor that question. Fortunately most desktop environments (for example, Windows and GNOME) allow the user to specify the striping mode to use.

But you can't find out though any Java API - and that bug's been open for over two years now, with no signs of progress.

So in the end, your Java UI is yet again stuck looking like crap because there's no way to tell Java just to render text however the host desktop environment would, which is all I really want to do.

Why is that so hard? Just do whatever the host desktop environment does and don't make me worry about LCD striping methods!

Topics: