Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8058742

Text size is twice bigger under GTK L&F on Gnome with HiDPI enabled

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 8, 9
    • Fix Version/s: 10
    • Component/s: client-libs
    • Environment:

      Linux Ubuntu: 14.04
      Gnome: 3.9.90
      JDK 1.8.0_40-ea

    • Subcomponent:
    • Understanding:
      Fix Understood
    • OS:
      linux

      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.

        Issue Links

          Activity

          Hide
          alexsch Alexander Scherbatiy (Inactive) added a comment -
          See the attached screenshot.
          First window: scaling-factor 1
          Second window: scaling-factor 2
          Show
          alexsch Alexander Scherbatiy (Inactive) added a comment - See the attached screenshot. First window: scaling-factor 1 Second window: scaling-factor 2
          Hide
          prr Philip Race added a comment -
          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 ..

          Show
          prr Philip Race added a comment - 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 ..
          Hide
          ssadetsky Semyon Sadetsky added a comment - - edited
          GTK LnF font scaling uses only native scale factor and does not take into account the global scale used for rendering.
          Show
          ssadetsky Semyon Sadetsky added a comment - - edited GTK LnF font scaling uses only native scale factor and does not take into account the global scale used for rendering.
          Hide
          vdyakov Victor Dyakov added a comment -
          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
          Show
          vdyakov Victor Dyakov added a comment - 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
          Show
          vdyakov Victor Dyakov added a comment - 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/

            People

            • Assignee:
              serb Sergey Bylokhov
              Reporter:
              alexsch Alexander Scherbatiy (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Due:
                Created:
                Updated: