Java Font Rendering: Should the AA generator be disabled for the AA subpixel?

I am trying to improve my graphics system written in Java to use sub-pixel anti-aliasing and was successful, with the exception of one remaining anomaly. This is the next question from my other question from yesterday .

The remaining problem is that setting the KEY_ANTIALIASING rendering hints to VALUE_ANTIALIAS_ON ignores KEY_TEXT_ANTIALIASING when it is set to AA (subpixel) AA. Can someone shed some light on this? I am currently forced to VALUE_ANTIALIAS_OFF before rendering the text and returning it after rendering the text (so another picture, like circles, etc., is equal to AA'd).

This problem has been proven using the standalone test program below. As you can see, if you run it, the circle will be painted AA when the font is gone, and vice versa. It would be nice if AA were set up to work for all of the painting.


Self test program

import java.awt.*; import java.awt.event.*; public class AwtTestFrame1c extends Panel { AwtTestFrame1c() { setBackground(SystemColor.control); } public void paint(Graphics gc) { Graphics2D g2d = (Graphics2D)gc; int py=0; py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,true ); py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,false); } private int paintText(Graphics2D dgc, int py, Object val, boolean aa) { char[] txt=("The quick brown fox jumped over the lazy dog ("+val+", General AA: "+aa+")").toCharArray(); if(aa ) { dgc.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON ); } else { dgc.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF); } if(val !=null) { dgc.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,val); } dgc.setFont(font); dgc.drawOval(5,py+5,15,15); dgc.drawChars(txt,0,txt.length,30,py+line-5); return (py+line); } static private final Font font=new Font("SansSerif",Font.PLAIN,16); static private final int line=25; static public void main(String[] args) { Frame wnd=new Frame("AWT Antialiased Text Sample"); wnd.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); wnd.add(new AwtTestFrame1c()); wnd.setSize(new Dimension(1000, 300)); wnd.setVisible(true); } } 
+6
java fonts rendering antialiasing
source share
2 answers

Shook a little, found this: error 6263951 .

Obviously bustage is fixed in b17? I am not quite sure how to interpret the error report.

Definitely broken here on 1.6.0_17-b04 (MacOS X 10.5).

+1
source share

I updated VirtualBox , so I took pictures. I can just see the rendering of the host, but I suspect that it also depends on the implementation.

Ubuntu 9.10 AwtTestFrame Ubuntu http://i48.tinypic.com/33k4od0.png Mac OS X 10.5 AwtTestFrame Mac http://i49.tinypic.com/14wypu0.png Windows 7 AwtTestFrame WIn http://i45.tinypic.com/ 21a0n7n.png

+2
source share

All Articles