Bug 508185 - Java GTK Swing LookAndFeel sets wrong font size
Summary: Java GTK Swing LookAndFeel sets wrong font size
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: java-1.6.0-openjdk
Version: 13
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Omair Majid
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-06-25 22:50 UTC by Joel Uckelman
Modified: 2013-01-21 20:31 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-27 14:15:38 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
a screenshot showing the problem (218.34 KB, image/png)
2009-06-25 22:50 UTC, Joel Uckelman
no flags Details
a test case exhibiting the problem (1.00 KB, text/x-java)
2009-06-26 16:47 UTC, Joel Uckelman
no flags Details

Description Joel Uckelman 2009-06-25 22:50:00 UTC
Created attachment 349485 [details]
a screenshot showing the problem

Description of problem:

The GTK LAF is supposed to pick up the correct default GUI font size from the desktop environment. This does not happen, as can be seen in the attached screenshot. 

In native GTK apps, capital letters are 10px high, while in Swing apps using the GTK LAF, capitals are only 9px high. The result is that the Swing apps look rather odd and out-of-place.


Version-Release number of selected component (if applicable):

java-1.6.0-openjdk-1.6.0.0-22.b16.fc11.x86_64

How reproducible:

Always.


Steps to Reproduce:
1. Run any Java app with the GTK LAF.

Actual results:

Text is slightly too small.

Expected results:

Text should be the same size as in GTK apps.

Additional info:

Please let me know if there's anything I can do to help troubleshoot this.

Comment 1 Omair Majid 2009-06-26 13:04:54 UTC
Hi Joel, 

Thanks for reporting this bug. However, I am unable to reproduce the issue. The only way I can cause differences in font sizes is by changing the GTK font sizes while the java application is running; the gtk programs react to the size change, while the java program doesnt. If I restart the java program, it gets the new font size correctly.

There must be something I am missing...

Comment 2 Joel Uckelman 2009-06-26 16:47:00 UTC
Created attachment 349578 [details]
a test case exhibiting the problem

Here's a test case which exhibits the problem for me.

Comment 3 Joel Uckelman 2009-06-26 18:58:02 UTC
I tested this on a fresh F11 install, just to be sure that I'm not seeing anything strange due to my normal setup, and I still see the same font size problem there.

Comment 4 Bug Zapper 2010-04-27 15:15:38 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 5 Joel Uckelman 2010-04-27 15:24:53 UTC
Still happens in Fedora 12.

Comment 7 Omair Majid 2010-06-30 14:25:44 UTC
Hi,

I can reproduce the problem now (wonder why I couldn't before...). You are correct: there is a difference between the font sizes in gtk and swing application.

Digging through the code, here is a comment I found in com.sun.java.swing.plaf.gtk.PangoFonrts:

[snip]
         * Finally this DPI is used to calculate the nearest Java 2D font
         * 72 dpi font size.
         * There are cases in which JDK behaviour may not exactly mimic
         * GTK native app behaviour :
[snip]
         * 3) Because of rounding errors sizes may differ very slightly
         * between JDK and GTK. To fix that would at the very least require
         * Swing to specify floating pt font sizes.
         * Eg "10 pts" for GTK at 96 dpi to get the same size at Java 2D's
         * 72 dpi you'd need to specify exactly 13.33.
[snip]

This seems to be the problem. If I set my dpi to 72 in gtk, then the swing and gtk font sizes match exactly (there are still kerning and antialiasing issues, but they are much harder to notice).

Comment 8 Joel Uckelman 2010-06-30 14:48:27 UTC
Great, I'm glad I've proven to you I'm not crazy. :)

What's the way forward on this? It seems like the way the JDK is doing it is completely broken.

Comment 9 Omair Majid 2010-06-30 20:18:34 UTC
I am not sure at all what happens next. 

I don't know if this can be fixed without breaking backwards compatibility. Assuming it can be, this is not going to be a trivial change. From a cursory look at the font related stuff, I can see there is some support for floats as font sizes in awt but integer font sizes remain the standard.

I am going to dig through the code a bit more to see if fixing this is possible at all, and if so, post a message to the OpenJDK mailing list to get some feedback.

Comment 10 Joel Uckelman 2010-10-13 10:30:01 UTC
Do you know of any workaround? Is there a way to detect the dpi so that I can correct for the problem in the meantime?

Comment 11 Joel Uckelman 2010-10-13 10:34:25 UTC
Aha. I think I have a workaround now: java.awt.Toolkit.getScreenResolution() will tell me (what the JVM thinks is) the DPI, so at least I can check whether I'm in a non-72dpi setting.

Comment 12 Bug Zapper 2010-11-04 10:58:10 UTC
This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 13 Omair Majid 2010-11-16 18:10:31 UTC
This bug has been fixed upstream: http://hg.openjdk.java.net/jdk6/jdk6/jdk/rev/9216ec4e4c14. It should be part of the next jdk6 source drop and IcedTea 1.10.

Comment 14 Joel Uckelman 2010-11-16 20:36:30 UTC
Thanks! Any idea when that will make its way to Fedora?

Comment 15 Omair Majid 2010-11-16 20:50:46 UTC
(In reply to comment #14)
> Thanks! Any idea when that will make its way to Fedora?

I believe that OpenJDK6 b21 should be released any time now. AFAIK they are waiting on a few blocker bugs. The IcedTea6 packages should be available shortly after (they have to undergo quite a bit of testing first). Personally, I expect Fedora 14 to have updated java packages by the end of the month. No promises ;)

Comment 16 Reinout van Schouwen 2011-04-11 10:23:37 UTC
I'm running OpenJDK 1.6.0_22 now on Fedora 15, and the menu fonts Netbeans uses in the GTK L&F are bigger than those on other applications. For instance, the contents of the Team menu don't fit on my 1280x800 laptop screen.

Comment 17 Omair Majid 2011-04-11 15:14:29 UTC
(In reply to comment #16)
> I'm running OpenJDK 1.6.0_22 now on Fedora 15, and the menu fonts Netbeans uses
> in the GTK L&F are bigger than those on other applications. For instance, the
> contents of the Team menu don't fit on my 1280x800 laptop screen.

Is this also happening with other Java applications (especially the ones that use Swing)? or is this just a problem with netbeans?

Comment 18 Reinout van Schouwen 2011-04-12 12:29:39 UTC
(In reply to comment #17)

> Is this also happening with other Java applications (especially the ones that
> use Swing)? or is this just a problem with netbeans?

As far as I can determine with my bare eyes, it happens on other Java Swing applications as well.

It turns out that if I use gnome-tweak-tool to make the Default and Document font one point smaller, the menus look better, but as the GTK+ font size is also reduced the fonts in Netbeans are still a bit larger than the rest.

Comment 19 Omair Majid 2011-04-12 20:30:42 UTC
(In reply to comment #18)
> (In reply to comment #17)
> 
> > Is this also happening with other Java applications (especially the ones that
> > use Swing)? or is this just a problem with netbeans?
> 
> As far as I can determine with my bare eyes, it happens on other Java Swing
> applications as well.
> 

Would it be possible for you to try out the test case in comment 2 ? Please try and compare that with gnome-terminal. If you can provide a screenshot, that would be great. It would be nice to find out if this is a problem specific to netbeans or a bug in openjdk.

> It turns out that if I use gnome-tweak-tool to make the Default and Document
> font one point smaller, the menus look better, but as the GTK+ font size is
> also reduced the fonts in Netbeans are still a bit larger than the rest.

On my machine with netbeans 6.8 and icedtea6 1.10, netbeans's menu's have the right sizes.

Comment 20 Bug Zapper 2011-06-02 17:59:09 UTC
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '13'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 21 Joel Uckelman 2011-06-02 18:16:09 UTC
This looks correct to me in java-1.6.0-openjdk-1.6.0.0-57.1.10.1.fc15.x86_64.

Comment 22 Bug Zapper 2011-06-27 14:15:38 UTC
Fedora 13 changed to end-of-life (EOL) status on 2011-06-25. Fedora 13 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.