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

Segoe UI font renders too heavy when ClearType is disabled

XMLWordPrintable

    • 2d
    • x86_64
    • windows

      ADDITIONAL SYSTEM INFORMATION :
      Java 11.0.11 and Java 17.0.1 (both tested), on Windows 11, with ClearType disabled in the Windows settings.

      A DESCRIPTION OF THE PROBLEM :
      On Windows 11 (and probably Windows 10), the font Segoe UI 12 Plain appears too heavy (almost bold) when ClearType is disabled at the operating system level.

      Segoe UI 12 has been the default UI font on Windows since Vista, although the Windows LAF has defaulted to Tahoma 11 for reasons of backwards compatibility. The NetBeans IDE has recently switched to Segoe UI 12 in both the Windows LAF and its cross-platform FlatLAF LAF, and a user who had ClearType disabled reported excessively bold UI fonts (see https://issues.apache.org/jira/browse/NETBEANS-6358 ).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      On Windows 10 or Windows 11, run the attached sample application, which will open a JFrame with two text samples. In the Windows Start Menu search bar, type "cleartype" and open the "Adjust ClearType text" app. Show the ClearType window and the Java window side by side, and toggle the "Turn on ClearType" checkbox.

      If you happen to be on a high-resolution monitor with HiDPI scaling enabled, be sure to disable HiDPI scaling first (100% scale on the Windows "Display" control panel page).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The text "This is a small test in Segoe UI 12" should remain equally heavy when ClearType is enabled or disabled.

      The "File" and "Edit" menus should look similar to the "File" and "Edit" menus in other applications (e.g. Notepad).
      ACTUAL -
      The text "This is a small test in Segoe UI 12" looks heavy (almost bold) when ClearType is disabled.

      The text "This is a small test in Tahoma 11", however, remains the same visual weight regardless of the ClearType setting.

      The "File" and "Edit" menus always remain unexpectedly bold, since these are always shown in Segoe UI 12 by default. Compare with e.g. the "File" and "Edit" menus in Notepad to see what these menus should actually look like.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.Color;
      import java.awt.EventQueue;
      import java.awt.Font;
      import java.awt.GridLayout;
      import java.awt.Toolkit;
      import javax.swing.UIManager;
      import javax.swing.UnsupportedLookAndFeelException;

      public class HeavySegoeExhibit extends javax.swing.JFrame {
        private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenu jMenu2;
        private javax.swing.JMenu jMenu3;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JPanel jPanel1;

        public HeavySegoeExhibit() {
          initComponents();
        }

        private void initComponents() {
          jPanel1 = new javax.swing.JPanel();
          jLabel1 = new javax.swing.JLabel();
          jLabel2 = new javax.swing.JLabel();
          jMenuBar1 = new javax.swing.JMenuBar();
          jMenu1 = new javax.swing.JMenu();
          jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
          jMenu3 = new javax.swing.JMenu();
          jMenu2 = new javax.swing.JMenu();

          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

          jPanel1.setBackground(new Color(255, 255, 255));
          jPanel1.setLayout(new GridLayout(2, 1));

          jLabel1.setFont(new Font("Tahoma", 0, 11));
          jLabel1.setText("This is a small test in Tahoma 11.");
          jPanel1.add(jLabel1);

          jLabel2.setFont(new Font("Segoe UI", 0, 12));
          jLabel2.setText("This is a small test in Segoe UI 12.");
          jPanel1.add(jLabel2);

          getContentPane().add(jPanel1, BorderLayout.CENTER);

          jMenu1.setText("File");
          jMenu2.setText("Edit");

          jCheckBoxMenuItem1.setText("SomeCheckBox");
          jMenu1.add(jCheckBoxMenuItem1);

          jMenu3.setText("Sub Menu");
          jMenu1.add(jMenu3);
          jMenuBar1.add(jMenu1);
          jMenuBar1.add(jMenu2);
          setJMenuBar(jMenuBar1);

          setSize(500, 300);
          
        }

        public static void main(String args[]) {
          System.out.println(System.getProperty("java.version"));
          try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          } catch (ClassNotFoundException | IllegalAccessException
              | InstantiationException | UnsupportedLookAndFeelException e) {
            throw new RuntimeException(e);
          }

          EventQueue.invokeLater(new Runnable() {
            public void run() {
              System.out.println(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"));
              new HeavySegoeExhibit().setVisible(true);
            }
          });
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      We could request that users always enable ClearType. Or we may end up detecting when ClearType is disabled, and revert to Tahoma 11 instead of the now-standard Segoe UI 12 font.

      FREQUENCY : always


        1. HeavySegoeExhibit.java
          3 kB
        2. Capture1.PNG
          Capture1.PNG
          54 kB
        3. Capture2.PNG
          Capture2.PNG
          53 kB

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: