Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4726365
Votes 378
Synopsis RFE: Java 2D to support LCD optimized anti-aliased text (sub-pixel resolution)
Category java:classes_2d
Reported Against 1.4 , tiger-beta2
Release Fixed mustang(beta)
State 10-Fix Delivered, request for enhancement
Priority: 5-Very Low
Related Bugs 6333887 , 5057760 , 5057309 , 4871297 , 4502804
Submit Date 05-AUG-2002
Description




FULL PRODUCT VERSION :
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)

FULL OPERATING SYSTEM VERSION :
 customer  Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The quality of Java2D text antialiasing leaves a lot to be
desired in comparison to OS naitve antialiasing, especially
ClearType on Windows.

Java2D uses gray scale antialiasing. At point sizes below a
certain threshold (around 14pt it seems) this just does not
look very  customer , with text appearing 'lumpy' and uneven.
Either the way antialiasing interacts with font hinting
needs to be improved, or there should be a settable
rendering hint so that text below a certain size is not
antialiased. In Windows standard text antialiasing, this
works well. Larger font sizes are antialiased, where the
most benefit is seen, and smaller font sizes are untouched,
making them legible.

Another problem is that Java2D antialiasing does not measure
up to subpixel addressable antialiasing like in ClearType or
 customer  CoolType (in Acrobat). ClearType/CoolType looks quite
 customer  even at smaller point sizes (12,pt, 10pt), and is much
sharper on digital LCD screens, and in my experience,
aperture grill monitors.

Finally, none of the Swing look and feels takes advantage of
antialiasing, probably because of its poor quality and
performance. This makes the Windows look and feel suffer in
comparison to native Windows applications.

One fix would be for Java2D to support ClearType style
antialiasing itself. A downside to this approach is that the
Java2D renderer would likely not gain the advantage of
hardware acceleration provided by native API's like Quartz
Extreme on Mac OS X, or in the future GDI+. Antialiasing is
performance intensive, so supporting the native OS rendering
path would have certain benefits.

And once antialiasing is acceptable for smaller point sizes,
Swing should support it in the Windows Look and Feel,
obeying the operating system settings for rendering options.
For example, if the user selects standard antialiasing in
the Control Panel, Swing should use grayscale antialiasing
for larger font sizes. If the user has picked ClearType,
Swing should use ClearType-style antialiasing for all point
sizes.


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER WORKAROUND :
Use older JDK's where rendering is down by the host OS. Use
.NET/GDI+ or other native OS api's.
(Review ID: 160298) 
======================================================================
Work Around
N/A
Evaluation
The request of supporting sub-pixel addressing is one that has been discussed
and considered desirable, but needs substantial work on the rasteriser which is
not likely to make any release in the near future.

The second issue of Swing's support for A-A text is not tied to the above
and is already targeted for the tiger release by Swing.

  xxxxx@xxxxx   2002-08-05
============================

See also
5057760:RFE: Java2D font anti-aliasing should support TrueType's gasp table

and Swing RFE's
4502804: FontSmoothing/AntiAlias not utilized by default despite OS setting
4871297: Win L&F: XP Look and Feel does not show ClearType anti-aliasing

(Its probably worth noting that the previous comment from 2002 that Swing will
add AA support in tiger was not in fact completed in tiger, except specifically
for the GTK L&F).

  xxxxx@xxxxx   2004-06-04
============================

We are working on this for the mustang release. A very small amount of
new API will be involved but we expect Swing's Windows L&F and GTK L&F's
to pick it up automatically so apps using those won't need to do anything
so long as their desktop is configured to use it too (ie Swing will honour
the desktop setting). Apps will also be able to explicitly request
it for text drawing on a Graphics2D by setting a simple RenderingHint.
  xxxxx@xxxxx   2005-1-26 20:55:04 GMT

whilst this is now fixed there are several follow-on RFE's.
6274808:Need new renderers that support 3 component masks (general LCD subpixel renderers)
6274813: RFE: Accelerate LCD glyphs via OpenGL pipeline
6274820: RFE: Accelerate LCD glyphs via D3D pipeline
6274830: RFE: API to discover/use the true LCD subpixel configuration of a display device.
6274842: RFE: Provide a means for a custom look and feel to use desktop font antialiasing settings.


  xxxxx@xxxxx   2005-05-23 22:22:22 GMT
Comments
  
  Include a link with my name & email   

Submitted On 10-AUG-2002
lstroud
Please have your font guys work on LCD screens instead of 
CRTs.  The java font difference is uncanny (actually the font 
difference in general).  In fact, I would have returned my LCD 
had it not been for XP's support of cleartext.  Recently when 
I started using intellij on my LCD, I struggled to find a font 
that is readable on a black background.  It seems that the 
antialiasing algorithm in swing narrows the font.  As such, it 
renders a font like arial virtually unreadable below 18 point.  
BTW, at 18 point it looks great.  However, that is a little big 
for dev work.  I would really, really like to see some 
improvements in the antialiasing for smaller fonts using 
subpixel algorithms.  


Submitted On 03-OCT-2002
filipsel
Please. Work on 1.5 client features that we are all hopping
will help Java on desktops, will not mean much if fonts will
look the way they do now on LCD's. And LCD screens are
gainig popularity very fast. And Swing fonts on them look
like joke. Especialy on Linux. Please do something. Please
be ahead of time for once regarding GUIs. Please surprise us
with something sooo cool and good and revolutionary, like
Apple did with their font implementation. Please, please,
please.


Submitted On 14-DEC-2002
billwhitelogin
This is a must have feature!  We have to have better 
anti-aliased fonts in the next release since more and more
users are moving to LCD panels and this will become vital!
PLEASE implement this.


Submitted On 19-DEC-2002
HESiemelink
So the reason why Java fonts have looked so miserably is 
that I've used an LCD screen for the past five years?? Maybe 
you guys should talk to Apple. For the unfortunately small 
period that I was in possession of a PowerBook I was amazed 
at how Swing apps could look! Font renedering was actually 
done properly on the Mac. (And IMHO a lot better than 
ClearType AND CoolType! I even stopped using Acrobat 
Reader in favor of the plain 'Preview' application)


Submitted On 21-JAN-2003
doofster
This is a simple enough feature to add, and the impression it 
makes on people is so great. I personally can't live without 
ClearType anymore.

Below is a piece of applet code I found on the internet that 
does something similiar to ClearType:

import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;

public class ClearType extends java.applet.Applet
{
  Font f = new Font("Times New Roman", Font.BOLD, 35);

  public void update(Graphics g)
  {paint(g);}

  public void paint(Graphics g)
  {
    g.setFont(f);
    g.drawString("Sample Text String", 5, getFontMetrics
(f).getHeight());
    drawClearType(g, "Sample Text String", 5, getFontMetrics
(f).getHeight()*3);
  }

  public int fuzz(int a, int b)
  {
    int red =   ((b >> 16) & 0xff)/3 + ((a >> 16) & 0xff);
    int green = ((b >> 8) & 0xff)/3 + ((a >> 8) & 0xff);
    int blue =  (b & 0xff)/3 + (a & 0xff);
    return (0xff << 24)|(red << 16)|(green << 8)|blue;
  }

  public void drawClearType(Graphics g, String s, int x, int y)
  {
    FontMetrics fm = getFontMetrics(f);
    int width = fm.stringWidth(s)*3;
    int height = fm.getHeight();
    Image img = createImage(width, height);
    Graphics grph = img.getGraphics();
    grph.setFont(f.deriveFont
(AffineTransform.getScaleInstance(3, 1)));
    grph.drawString(s, 0, height-fm.getMaxDescent());
    int[] pixelsA = getPixelArray(img);
    int[] pixels = new int[pixelsA.length];
    int[] newpixels = new int[(width/3)*height];
    for (int i = 0; i < width*height; i++)
    {
      newpixels[i/3] = (0xff << 24);
      if (i != width*height-1)
        pixels[i+1] = fuzz(pixels[i+1], pixelsA[i]);
      pixels[i] = fuzz(pixels[i], pixelsA[i]);
      if (i != 0)
        pixels[i-1] = fuzz(pixels[i-1], pixelsA[i]);
    }
    for (int i = 0; i < width*height; i++)
      switch(i%3)
      {
        case 0:
          newpixels[i/3] |= (pixels[i]) & 0xff0000;
          break;
        case 1:
          newpixels[i/3] |= (pixels[i]) & 0xff00;
          break;
        case 2:
          newpixels[i/3] |= (pixels[i]) & 0xff;
          break;
      }
    g.drawImage(imageFromPixels(newpixels, width/3, height), 
x, y-height, width/3, height, this);
  }

  private int[] getPixelArray(Image img)
  {
    int width = img.getWidth(this);
    int height = img.getHeight(this);
    int[] pixels = new int[width * height];
    PixelGrabber pg = new PixelGrabber(img, 0, 0, width, 
height, pixels, 0, width);
    try {pg.grabPixels();}
    catch(Exception e){}
    return pixels;
  }

  private Image imageFromPixels(int[] pixels, int width, int 
height)
  {
    return getToolkit().createImage(new MemoryImageSource
(width, height, pixels, 0, width));
  }
}


Submitted On 07-JUL-2004
robertabbe
Cleartext is very important for the creation of professional looking applications.  Please give this some serious consideration.


Submitted On 07-JUL-2004
robertabbe
Cleartext is very important for the creation of professional looking applications.  Please give this some serious consideration.


Submitted On 07-JUL-2004
gerry_giese
High quality text with sub-pixel antialiasing is a must for any modern display system.  I've recently been moving from web programming to GUI client programming, and was surprised that this situation exists.  The highest quality text using antialiasing should always come "free", and this is an important issue.  I consistently work with small font sizes, so this is even more important to me as a developer as more and more of my tools are written in Java as well.  Please get this working!  Save our eyes!


Submitted On 07-JUL-2004
robertabbe
Cleartext is very important for the creation of professional looking applications.  Please give this some serious consideration.


Submitted On 07-JUL-2004
activ8r
more and more people work on lcd (laptop and desktop), and since we are developping for professionals in the building construction field, and those people take laptops with them, the cleartype support would be clearly desirable.


Submitted On 08-JUL-2004
chrriis@brainlex.com
Java on the desktop needs such feature. Make it happen!


Submitted On 08-JUL-2004
giacobbej
A very useful feature that will further the adoption of Java on the desktop


Submitted On 08-JUL-2004
Maris_Orbidans
please implement this.

just  imagine  how cool would be to have multiplatform nice fonts.


Submitted On 08-JUL-2004
Mik
Java2D text needs some improvements both on the quality side and on the API side.
From the quality side, the stroking quality achieved on win is really bad, expecially if compared to what we see on MacOSX.
From the API side we really miss some serious kerning handling.


Submitted On 09-JUL-2004
robi
Well having logged this bug two years ago, I can finally release my votes for other stuff. Thank you all for piling on this one.

Though I love the general architecture of Swing/Java 2D, these guys really need the screws put to them on getting the implementations right. It's taken a long time to get the Windows PLAF looking OK (present bug excepted). now it sounds like subpixel antialiasing won't be in until 5.1 (cough 1.5.1 cough) or 6.0.  

I would have to really question their product planning when ClearType shipped in XP in 2001, and was announced months earlier. Please stop playing catch-up all the time. Read a few MSDN articles and get informed on what's coming down the pipe.

For example, MS is going to be hardware accelerating ClearType in Longhorn using pixel shaders. I hope those clever folks on the Java 2D team are reading up on shaders and can do the same.


Submitted On 09-JUL-2004
rcrobs
Agreed with all posters over recent days.  Swing applications will never take receive widespread acceptance until they look 100% like native applications.  The addition of ClearType or a similar technology to Swing is, as far as I see it, essential.  Java apps currently stand out a mile without it.


Submitted On 09-JUL-2004
jj_s23@yahoo.com
Definitely


Submitted On 09-JUL-2004
vladimirkondratyev
Definitely, this feature allows Java to look more native on desktop.


Submitted On 12-JUL-2004
maran457
A must have


Submitted On 14-JUL-2004
rexguo
Please implement this! It will make the text controls virtually indistinguishable from native Windows.


Submitted On 18-JUL-2004
Morten_Moeller
Well, if this doesn't make it in Tiger, it won't ever. I guess SWT will be the standard for making desktop UI applications. (now does that provoke the swing team enough to get this done? :))


Submitted On 31-AUG-2004
germana_p
This is a must have feature!  We have to have better 
anti-aliased fonts!!
PLEASE implement this.


Submitted On 09-SEP-2004
irun5k
Well, I don't get it.  Tiger is full of new stuff that I will never use and things that were easy to work around.  It isn't like the lack of Generics in 1.4 made Java totally useless.  However, this HUGE, in your face impossible to work around issue of GUI fonts is basically treated like a bastard child.  Come on guys, Apple got it right and they are an OS vendor- and a small one at that compared to MS.  You guys are the ones who invented Java!!! You're telling me this issue is too complicated for you to implement?  If this is true, the media is right.  Sun is going out of business.


Submitted On 11-SEP-2004
bugmenot3
Java UI looks butt ugly without this. How can you Java developers even stand staring at the sucky non cleartype fonts on Java apps all day! You guys will NEVER catch up with Microsoft this way. 


Submitted On 13-SEP-2004
zz82
I strongly recommend Swing developpers of Sun or other responsible team to implement subpixel (ClearType) AA, because it is so important and urgent! Java itself will be much more attractive and professional if having a  ClearTyped-AA.


Submitted On 11-JAN-2005
cowwoc
This is the final issue that prevents Java from looking native under Windows (as long as you use JGoodies Looks or WinLAF on top of the JRE). JGoodies Looks and WinLAF will not be able to add sub-pixel rendering themselves; this must come from the JRE.

Please commit this issue to Mustang.


Submitted On 25-JAN-2005
raj_madhu
I


Submitted On 25-JAN-2005
raj_madhu
I'm seriously considering switching my apps to RCP (using SWT) JUST because of this one missing feature.. Do you hear me??


Submitted On 05-FEB-2005
vladimirkondratyev
I


Submitted On 12-APR-2005
linuxhippy
please do that, or I


Submitted On 10-JUN-2005
pweemeeuw
It looks great now, thanks !



PLEASE NOTE: JDK6 is formerly known as Project Mustang