Reputation: 93318
I'm writing a Graphically intense application that renders a JLabel offscreen.
When I call the following line, ellipsis appear on the mac but not on the windows box.
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
Now, I'm guessing that it's caused by Mac already doing some subpixel rendering of fonts, but I'd just like to confirm it.
Also, since on it's imperative that FRACTIONALMETRICS be enabled on windows (the app looks terrible otherwise), can anyone suggest a work around short of adding a check for not mac?
Thanks.
Upvotes: 1
Views: 1375
Reputation: 4540
The RenderingHints for FractionalMetrics are concerned with rounding floats to ints when sizing or kerning fonts. The glyphs themselves are unaffected by this setting. You can read all about this at the Java 2D FAQ.
You are correct that Java on Mac OS X is enabling text anti-aliasing at a system level, and Windows is not, but there's no need for a Mac-only check. What you should do is set the TextAntiAlias RenderingHint on instead.
gfx.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON
);
Java 6 supports ClearType font rendering which is much better on LCD screens than the anti-aliasing that was in Java 5. ClearType often needs to be switched on Windows XP; it's somewhere in the display settings in the Control Panel. Then you need to run your Java program with the correct command-line arguments to enable it (or insert them into System.setProperty() before you display any Swing components):
java -Dawt.useSystemAAFontSettings=lcd [...your gubbins here...]
Upvotes: 3