The Source for Java Technology Collaboration

Home » java.net Forums » JDK » 6uN Early Access

Thread: b13 - Text antialiasing problems for TTF fonts (loaded via classloader)

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 6 - Last Post: Mar 25, 2008 10:52 AM by: trembovetski Threads: [ Previous | Next ]
nazmulidris

Posts: 25
b13 - Text antialiasing problems for TTF fonts (loaded via classloader)
Posted: Mar 23, 2008 11:33 PM
 
  Click to reply to this thread Reply

I've been using UpdateN b13 and I'm really impressed with the fantastic looking font rendering on Windows Vista! Great job on the implementation!

I've noticed one issue - for the Java app that I'm building, I load TTF files from my hard drive, via a classloader. When I create fonts that are loaded in this way, the antialising/rendering of text doesn't look right. So it looks great for "system loaded fonts", but for custom fonts that I load, the text doesn't look right. I can copy the same exact TTF that Vista uses, and load it via a classloader and text rendering doesn't look right.

Here's the code I use:

String fontFile = "fonts/Segoe UI.ttf";
InputStream is = ClassLoader.getSystemResourceAsStream(fontFile);
Font font = Font.createFont(Font.TRUETYPE_FONT, is);
is.close();

Do you know what's going on with the font rendering?

Also, I use SwingX components, and the font rendering on all of them is off... the default Swing text components look much better than their SwingX counterparts.

Thanks,
Nazmul

trembovetski

Posts: 644
Re: b13 - Text antialiasing problems for TTF fonts (loaded via classloader)
Posted: Mar 24, 2008 10:00 AM   in response to: nazmulidris
 
  Click to reply to this thread Reply

Could you please post some screenshots of what you mean by "doesn't look right" (in png's, please)?

Dmitri

trembovetski

Posts: 644
Re: b13 - Text antialiasing problems for TTF fonts (loaded via classloader)
Posted: Mar 24, 2008 10:00 AM   in response to: trembovetski
 
  Click to reply to this thread Reply

And a test case would be even better.

nazmulidris

Posts: 25
Re: b13 - Text antialiasing problems for TTF fonts (loaded via classloader)
Posted: Mar 24, 2008 3:56 PM   in response to: trembovetski
 
  Click to reply to this thread Reply

Hi Dimitri

I've attached a Zip file which has PNG files as you requested, and the code that loads the fonts from the hard drive. I'm using Vista SP1 Enterprise, and the fonts that I load from the hard drive are the same TTF files that are in the Vista Fonts folder.

The FontUtils.java class loads some fonts (from the hard drive) and then sets UIDefaults for Swing components.

If you look inside the Zip file you will find the 2 PNG files. If you look at b13-systemfonts.png, this is the screenshot using 'system loaded' fonts - ie, I don't load these fonts in my code... they are available from Vista. Everything looks good here. In order to get this result, I've disabled the code in FontUtils that actually loads the TTF files from the classloader.

If you look at b13-classloadedfonts.png, this is the screenshot using 'classloader loaded' fonts, from the hard drive. These are the same TTF files that are used by Vista, but when I load them 'manually', the font rendering is "off". If you compare the 2 PNG files side by side, you will see that the antialiasing is different...

Let me know if you need anything else.

Thanks,
Nazmul.

trembovetski

Posts: 644
Re: b13 - Text antialiasing problems for TTF fonts (loaded via classloader)
Posted: Mar 24, 2008 8:34 PM   in response to: nazmulidris
 
  Click to reply to this thread Reply

Thanks for the info, Nazmul.

According to our fonts engineer, this is by design: rendering of fonts created with
createFont goes through the built-in rasterizer instead of using the native one.

Dmitri

nazmulidris

Posts: 25
Re: b13 - Text antialiasing problems for TTF fonts (loaded via classloader)
Posted: Mar 24, 2008 9:40 PM   in response to: trembovetski
 
  Click to reply to this thread Reply

Thanks Dimitri. So are there any plans to update the built-in rasterizer to more closely match ClearType?

In my code, I can check to see what OS the app is running on to make sure that certain fonts are available, before trying to load them from disk...

Again, I'm really impressed with the native font rasterization. It looks great!!! I can't use any VM other than b13 because of it :).

Take care
Nazmul.

trembovetski

Posts: 644
Re: b13 - Text antialiasing problems for TTF fonts (loaded via classloader)
Posted: Mar 25, 2008 10:52 AM   in response to: nazmulidris
 
  Click to reply to this thread Reply

> So are there any plans to update the built-in rasterizer to more closely match ClearType?

This is an ongoing process, there are bugs filed against specific issues.

Good to hear that you like the new font rendering in 6u10!

Dmitri




 XML java.net RSS