anti-aliasing : Java Glossary

anti-aliasing
A technique of making fonts look smoother on screen by using blended colours in the pixels around the edges of letters. It fools the eye into thinking that the edges are sharper than they really are.

You can get W2K/XP to anti-alias with Start ⇒ Control Panel ⇒ Display ⇒ Effects ⇒ Smooth edges of screenfonts. You can get Vista to anti-alias with Start ⇒ Control Panel ⇒ System and Maintenance ⇒ Performance Information and Tools ⇒ Adjust Visual Effects (on left) ⇒ smooth edges of screen fonts.

. You can get Vista to anti-alias with Start ⇒ Control Panel ⇒ System and Maintenance ⇒ Performance Information and Tools ⇒ Adjust Visual Effects (on left) ⇒ smooth edges of screen fonts.

With an LCD (Liquid Crystal Display) monitor, you want subpixel anti-aliasing called ClearType. To turn it on click Start ⇒ Control Panel ⇒ Appearance and Personalization ⇒ Personalization ⇒ Windows color and appearance ⇒ Open classic colour and appearance ⇒ Effects ⇒ ClearType.

Without anti-aliasing, you will see jagged diagonal lines especially in the large sizes of spidery fonts with thin diagonal lines (e. g. Bodoni, Book Antiqua, Garamond, Serif and Zapf Calligraphic) especially on the capital W. Sun, even when anti-aliasing, pays no attention to the font rendering hints. This why small font sizes are so grungy looking. Anti-aliasing is primarily to make large font sizes look better.

Appearance In Java 1.6
In Java 1.2 Anti-aliasing Gotchas
In Java 1.3 Links
In Java 1.4

What Does Anti-aliasing Look Like?

You can compare the same fonts anti-aliased and plain using the FontShower for Swing amanuensis which will display fonts in various sizes and colours with and without anti-aliasing and in the FontShower for AWT Applet in canvas mode. You are certain to see fonts without anti-aliasing in the FontShower for AWT Applet in canvas mode under W95/W98/Me/NT/W2K. You are certain to see anti-aliasing in the FontShower for Swing under XP/W2003/Vista/W7-32/W7-64. The font where the differences are most obvious is DPCustomMono2.
Without anti-alias Anti-aliased
DPCustomMono2 unaliased DPCustomMono anti-aliased
The further back you stand, the more the samples look alike. Anti-aliasing is a similar sort of blurring that ironically creates the illusion of sharpness.

Several influences combine to decide whether you will get anti-aliasing:

Anti-aliasing in Java version 1.2

To anti-alias fonts in AWT (Advanced Windowing Toolkit), you have to go through a gambit like this in your Canvas

There is another technique that uses an undocumented Sun class.

It won’t do you any good to override the paint method of a peered Component such as Label, TextField or TextArea since the rendering is handled by the peer. Whether they are anti-aliased is determined by the OS (Operating System) Control Panel.

Anti-aliasing in Java version 1.3

Anti-aliasing in Swing is similar to AWT, except that you override paintComponent instead of paint.

Smooth Metal LAF (Look And Feel) adds anti-aliasing to various Sun LAFs.

WrapLF is a LAF that lets you insert your own code.

Anti-aliasing in Java version 1.5

In Java version 1.5 you don’t have to override paint methods.
Since Java version 1.5, it is possible to set the system property globally with swing.aatext=true. You can do that with java.exe -Dswing.aatext=true on the command line. Unfortunately the results are not always desirable. Sometimes small fonts look worse anti-aliased.

Anti-aliasing in Java version 1.6

The Java 1.6, has yet another anti-aliasing scheme, one that allows sub-pixel anti-aliasing that takes advantage of the geometry of the tiny red, green and blue phosphor dots on a CRT (Cathode Ray Tube), or the equivalent dots on an LCD panel, that make up each pixel. Microsoft uses a scheme like this in Vista they call ClearType. In Java version 1.6 there is a system property called awt.useSystemAAFontSettings you can use to control anti-aliasing. Possible values include: In Java version 1.6 or later there are also new values to use in setRenderingHints key and value, including VALUE_ANTIALIAS_OFF to turn anti-aliasing off.

Anti-aliasing Gotchas

Learning More

Oracle’s Javadoc on RenderingHints class : available:
Oracle’s Technote Guide on anti-aliasing : available:

ClearType
fonts
FontShower for AWT: display fonts in various sizes and colours without and without anti-aliasing
FontShower for Swing: display fonts in various sizes and colours without and without anti-aliasing

CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/antialiasing.html J:\mindprod\jgloss\antialiasing.html
logo
Please email your , letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email. If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, please quote it and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. Threatening to kill me or spouting obscenities has yet to persuade me to change my mind.
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.179.212]
You are visitor number 45,111.