JDK-8058742 : Text size is twice bigger under GTK L&F on Gnome with HiDPI enabled
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,9
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • Submitted: 2014-09-18
  • Updated: 2022-11-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
Steps to reproduce:

Run the code:
-----------------------
import javax.swing.*;
import com.sun.java.swing.plaf.gtk.GTKLookAndFeel;

public class GnomeHiDPITest {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            try {
                UIManager.setLookAndFeel(new GTKLookAndFeel());
                JFrame frame = new JFrame();
                frame.setSize(100, 100);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                JMenuBar menuBar = new JMenuBar();
                menuBar.add(new JMenu("Test 1"));
                menuBar.add(new JMenu("Test 2"));
                frame.setJMenuBar(menuBar);
                frame.setVisible(true);
            } catch (UnsupportedLookAndFeelException ex) {
                throw new RuntimeException(ex);
            }
        });
    }
}
-----------------------

- Enable HiDPI
> gsettings set org.gnome.desktop.interface scaling-factor 2

The text menu size is enlarged.

Note that under Metal L&F the text size is not changed.


Comments
http://mail.openjdk.java.net/pipermail/swing-dev/2016-July/006255.html http://mail.openjdk.java.net/pipermail/swing-dev/2016-November/006911.html http://cr.openjdk.java.net/~ssadetsky/8058742/webrev.01/
13-12-2016

This is deferred as non-reg-9 , nevertheless you can fix it in 9, in such case please re-target right before your fix push
09-09-2016

GTK LnF font scaling uses only native scale factor and does not take into account the global scale used for rendering.
05-07-2016

share/classes/com/sun/java/swing/plaf/gtk/PangoFonts.java has some code that that tracks Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI"); I imagine this DPI value is increased in hidpi mode and we end up with a font that is perhaps the correct pixel size for hi-dpi but as the rest of the GTK L&F is not respecting it .. we are then auto-scaled .. and everything is pixel-doubled (or whatever the ratio is). So doing anything with that code is probably a work-around for the lack of hi-dpi awareness in AWT/ GTK L&F ..
19-09-2014

See the attached screenshot. First window: scaling-factor 1 Second window: scaling-factor 2
18-09-2014