Skip to main content

Are we ever going to get good looking fonts in Swing?

26 replies [Last post]
jacek
Offline
Joined: 2003-08-22
Points: 0

Swing has had many complaints over the years, but I really see big improvements in latest versions that make the SWT vs Swing arguments less relevant.

However, one thing in Swing that sticks out like a sore thumb is the poor font rendering. I mean, on my W2K box the fonts look really amateurish, especially size 8-10 pt, the "8" character looks chopped up and reminds me of the resolution on my old Commodore 64.

Are there any plans to bring font rendereing in Swing that would be comparable to native toolkits? Right now it's really quite obvious (and why isn't it using the right font in JFileChooser?)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jeff
Offline
Joined: 2003-06-10
Points: 0

From the Java2D team:

> BTW, here's another example of the truncated HTML
> label (or HTML renderer) truncated "W" problem ...
>
> http://www.jidesoft.com/images/wizard_java_steps_help.
> png

http://www.jidesoft.com/images/wizard_java_steps_help.png

Ah the infamous "W"., That's probably 11 pt Arial where the
W has a negative left side bearing.
Scott Violet knows this one well and just recently sent me a
snapshot of the exact same problem in GAIM on Windows!
So this is not a specifically Java problem. I've even seen
the exact same clipping in earlier versions of Internet Explorer.

So its a bug in whatever is using that font - doesn't look
like a JTextField to me.
In a nutshell if you draw text at X-axis location 0, that location
is used to position the string but DOES NOT MEAN that all the
text is to the right. Pixels can be drawn to the left and there
is no easy or efficient way to know this without calling costly
APIs. The easiest thing that is almost certain to work is to
always leave 1 pixel of space. So you position text at x=1

augusto
Offline
Joined: 2003-06-11
Points: 0

> From the Java2D team:
>
> http://www.jidesoft.com/images/wizard_java_steps_help.
> png
>
> Ah the infamous "W"., That's probably 11 pt Arial
> where the
> W has a negative left side bearing.
> Scott Violet knows this one well and just recently
> sent me a
> snapshot of the exact same problem in GAIM on
> Windows!
> So this is not a specifically Java problem. I've even
> seen
> the exact same clipping in earlier versions of
> Internet Explorer.
>
> So its a bug in whatever is using that font - doesn't
> look
> like a JTextField to me.

I see it on JLabels that are using HTML. The same lable in this example:
http://mycgiserver.com/~sellmic/java/htmllabeltruncate.png

Now if I did "Welcome" instead of "Welcome" it works fine. It's the same class, JLabel, but whatever is used to render it obviously does something differently. Not sure how I make it shift one pixel ...

> In a nutshell if you draw text at X-axis location 0,
> that location
> is used to position the string but DOES NOT MEAN that
> all the
> text is to the right. Pixels can be drawn to the left
> and there
> is no easy or efficient way to know this without
> calling costly
> APIs. The easiest thing that is almost certain to
> work is to
> always leave 1 pixel of space. So you position text
> at x=1

Is that what you guys are doing in 1.5? Because as I show in the image above, it seems to work great in 1.5.

Scott Violet

There's a couple of bugs people are talking about here.

The infamous 'W' problem. This was fixed as part of bug 4716362
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4716362).
Unfortunately it would appear this is still broken if the JLabel is
rendering html text. I've filed bug 5081024 on this, it'll show up on
JDC in a couple of days.

Using the wrong font font on XP/2k. We realize this is a huge
detraction. We need to do an extra level of mapping for XP/2k to pick
up the correct font. Details for this are in 5079742 (not yet on
JDC).

-Scott

cowwoc
Offline
Joined: 2003-08-24
Points: 0

From personal experience, I believe this is a regression from J2SE 1.4

I specifically remember comparing Netbeans 4.0 running under JDK 1.4 and JDK 1.5 and the latter looked noticably worse.

Scott Violet

We're working on what release we can put this in. Mustang is the
current catch-all, but we're lobbying for an earlier release as it's
so important to everyone.

Is this ugly? YES! Is it a regression? We've never used Tahoma, so,
no. On 2k/XP, assuming you haven't touched anything, it's possible to
get components from the OS that use MS Sans Serif or Tahoma. For
example, compare the fonts on display properties with the popup that
comes up by right clicking on the desktop. Display properties uses MS
Sans Serif, where as the popup uses Tahoma. Confusing. Windows
appears to offer different styles for Components that will effect what
font they end up using, hence the difference between the two dialogs.

-Scott

jacek
Offline
Joined: 2003-08-22
Points: 0

I guess I should mention that I'm on W2K. BTW, my system font is Tahoma and to be honest none of the fonts in that shot look like Tahoma...that's probably another set of issues.

Does Swing always use the proper system font?

keithkml
Offline
Joined: 2003-06-10
Points: 0

> I guess I should mention that I'm on W2K. BTW, my
> system font is Tahoma and to be honest none of the
> fonts in that shot look like Tahoma...that's probably
> another set of issues.
>
> Does Swing always use the proper system font?

No, for some reason, Swing's Windows Look And Feel doesn't use the font that Windows uses. (This is Issue #13 for the Windows Look and Feel Fidelity Project at https://winlaf.dev.java.net/release_0.4.html#Issue13 )

jacek
Offline
Joined: 2003-08-22
Points: 0

Well, that's the main issue I suppose.

Second is that whatever other font it is using instead of Tahoma looks quite poorly.

augusto
Offline
Joined: 2003-06-11
Points: 0

Jeff, so do you have any idea what's going on with this? I generated a simple test for this, and I see it when I run stuff in 1.5beta2

http://mycgiserver.com/~sellmic/java/j15fontproblem.png

Now I know why so many people where complaining about fonts in JavaOne ... I could swear I've seen this before 1.5 beta though, might be a regression. It's pretty serious, these fonts look horrible!

Speaking of fonts, one font problem I have in my 1.4.2 client is that HTML JLabels truncate their strings, but this seems to be fixed in 1.5, so that's good! Too bad the fonts look pretty bad, hopefully this will get fixed before final ...

http://mycgiserver.com/~sellmic/java/htmllabeltruncate.png

augusto
Offline
Joined: 2003-06-11
Points: 0

BTW, here's another example of the truncated HTML label (or HTML renderer) truncated "W" problem ...

http://www.jidesoft.com/images/wizard_java_steps_help.png

jeff
Offline
Joined: 2003-06-10
Points: 0

Hi all,

Here's a response from the 2d team:

This is Microsoft Sans Serif. I used the windows native notepad
app and typed in the same text and set the size to 8pts. For
every glyph except the 8 and the C we are pixel identical with
what Microsoft produce. So it comes down to some small differences in
us vs MS in this one font, which we already know about as bug id
4924220. the C and the 8 are specifically what's complained about
in that bug.

jacek
Offline
Joined: 2003-08-22
Points: 0

It still doesn't answer the other main question: why are they using MS Sans Serif when I am using Tahoma on all my settings?

augusto
Offline
Joined: 2003-06-11
Points: 0

I'll second that question. Seems like a L&F problem. The nasty thing about this bug is that this is the default font and font size for their windows apps. Since I like to use the desktop defaults, this is just sticking out like a sore thumb and making swing apps look horrible.

BTW, in the bug report it says this problem shows up for Tahoma, haven't tried that yet. The bug report also says this is a 1.4 problem, but like I show in my images, it doesn't happen for me on 1.4.2_02

xhq
Offline
Joined: 2003-06-15
Points: 0

I ever tried to submit a bug 2 times on this regard. But I got "Not a bug" the first time, and the second time it just went to null after being assigned an interal review ID.

Scott Violet

Folks,

Heres a summary of the bugs to vote for:

Subpixel rendering (aka cleartype): 4726365
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4726365).

Swing should use Tahoma: 5079742
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5079742).

Clipping of 'W's when html text is displayed on component: 5081024
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5081024).

-Scott

jacek
Offline
Joined: 2003-08-22
Points: 0

Bug 5079742 (i.e. not using Tahoma) was only fixed in MUSTANG? How far away is that? 2 years?

C'mon guys. backport it to 1.5 before the final release date...it's one of the most obvious, glaring differences between Swing and native, pls don't delay another year or more!

mthornton
Offline
Joined: 2003-06-10
Points: 0

I think there is no chance of it being fixed for 5.0, but perhaps it could be pushed into 5.1 (is there a code name for 5.1 yet?).

augusto
Offline
Joined: 2003-06-11
Points: 0

I was going to ask about this too! What's going on here? Mustang?????!!!!!?????

At the very least it should be in a 1.5_01 release, but to be quite honest, it's such a noticable visual bug that it should be finxed in the first release of 1.5!

jacek
Offline
Joined: 2003-08-22
Points: 0

The SWT folks will have a field day with this one *sigh*

Really, doing Java GUIs is such a pain.

If you want nice API go with Swing...and deal with it's plethora of L&F bugs and other related issues (international keyboard support, etc.)

If you want performance and proper L&F go with SWT...but deal with it's sub-par API (has anyone tried to do an editable table using SWT/JFace? it's an exercise in horror).

jacek
Offline
Joined: 2003-08-22
Points: 0

So...any chance this fix will go into 5.0 or not?

jeff
Offline
Joined: 2003-06-10
Points: 0

> However, one thing in Swing that sticks out like a
> sore thumb is the poor font rendering. I mean, on my
> W2K box the fonts look really amateurish, especially
> size 8-10 pt, the "8" character looks chopped up and
> reminds me of the resolution on my old Commodore 64.

Hi jacek,

Can you post a screenshot? We'd like to see exactly what you're seeing.

thanks

jacek
Offline
Joined: 2003-08-22
Points: 0

How can I post a screenshot here? Unlike most other bulleting boards, this one does not have any functionality to upload an image into a msg?

jeff
Offline
Joined: 2003-06-10
Points: 0

You're right - we don't have image uploading set up.

You can either upload it to your own website and post a link, or you could email an image to us:

jeff @ sun . com (without the spaces) will work, and I'll upload it somewhere for you.

jeff

jeff
Offline
Joined: 2003-06-10
Points: 0

Here's the image from jacek:

http://www.holyzoo.com/~jeff/java/java_font.png

jacek's commentary:

>Notice how in the "538 k" in the screenshot the "8" is
>squashed in the middle and has some weird blocky pixels.
>Same thing for the "Cancel" on the button, especially the
>"C" looks very blockish, but the rest of the
>text doesn't exactly look very smooth either.

Message was edited by: jeff

zander
Offline
Joined: 2003-06-13
Points: 0

Hmm; I find the anti-aliasing more lacking. Its really looking silly compared to more mature (and free) software.
Its really obvious on lower font-sizes (font dialog-8 in my example)
http://uic.sf.net/badfonts.png

Just start http://uic.sf.net/demo/configdiag.jnlp to see for yourself.

The overlay is a KDE/Qt dialog with standard X11 fonts and anti-aliasing.

zander
Offline
Joined: 2003-06-13
Points: 0