Bug 508185 - Java GTK Swing LookAndFeel sets wrong font size
Java GTK Swing LookAndFeel sets wrong font size
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: java-1.6.0-openjdk (Show other bugs)
13
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Omair Majid
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-25 18:50 EDT by Joel Uckelman
Modified: 2013-01-21 15:31 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-06-27 10:15:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


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

  None (edit)
Description Joel Uckelman 2009-06-25 18:50:00 EDT
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 09:04:54 EDT
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 12:47:00 EDT
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 14:58:02 EDT
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 11:15:38 EDT
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 11:24:53 EDT
Still happens in Fedora 12.
Comment 7 Omair Majid 2010-06-30 10:25:44 EDT
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 10:48:27 EDT
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 16:18:34 EDT
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 06:30:01 EDT
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 06:34:25 EDT
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 06:58:10 EDT
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 13:10:31 EST
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 15:36:30 EST
Thanks! Any idea when that will make its way to Fedora?
Comment 15 Omair Majid 2010-11-16 15:50:46 EST
(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 06:23:37 EDT
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 11:14:29 EDT
(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 08:29:39 EDT
(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 16:30:42 EDT
(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 13:59:09 EDT
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 14:16:09 EDT
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 10:15:38 EDT
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.