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

Incorrect 'Segoe UI Semibold' font rendering on Windows with subpixel antialiasing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • tbd
    • 8, 11, 13
    • client-libs
    • None
    • Windows 10 (version 1809, build 17763.914)

    • 2d
    • windows

      To reproduce, run the program with the source code given below.

      Expected result: two 'club suit' symbols are rendered in the program window (possibly having different styles).
      Actual result: one 'club suit' symbol and one 'spade suit' symbol are rendered (see attached image).

      --- Test program source code ---
      import javax.swing.*;
      import java.awt.*;

      public class SegoeUiTest {
          public static void main(String[] args) {
              SwingUtilities.invokeLater(() -> {
                  JFrame frame = new JFrame();
                  frame.add(new MyComponent());
                  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                  frame.setSize(200, 100);
                  frame.setLocationRelativeTo(null);
                  frame.setVisible(true);
              });
          }

          private static class MyComponent extends JComponent {
              private static final String FONT_FAMILY = "Segoe UI Semibold";
              private static final String CLUB_SUIT = "\u2663";

              @Override
              protected void paintComponent(Graphics g) {
                  ((Graphics2D)g).setRenderingHint(
                          RenderingHints.KEY_TEXT_ANTIALIASING,
                          RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB
                  );
                  g.setFont(new Font(FONT_FAMILY, Font.PLAIN, 24));
                  g.drawString(CLUB_SUIT, 50, 40);
                  g.setFont(new Font(FONT_FAMILY, Font.BOLD | Font.ITALIC, 24));
                  g.drawString(CLUB_SUIT, 110, 40);
              }
          }
      }
      --------------------------------

            prr Philip Race
            dbatrak Dmitry Batrak
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: