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

[macos] Font substitution does not work for supplementary characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8, 9
    • client-libs
    • 2d
    • b150

      MacOSX supports automatic font fallback for unicode code points
      not supported by a specified font.
      JDK has implementation support to have that work in JDK too.

      However this is not working for unicode supplementaray characters represented by surrogate pairs as demonstrated
      by this test:

      import javax.swing.*;
      import java.awt.*;

      public class SurrogatesFallbackTest {
          public static void main(String[] args) {
              SwingUtilities.invokeLater(() -> {
                  JFrame frame = new JFrame();
                  JLabel label = new JLabel(new String(Character.toChars(0x1d400))); // MATHEMATICAL BOLD CAPITAL A
                  label.setFont(new Font("Menlo", Font.PLAIN, 36)); // expected to fallback to STIXGeneral
                  frame.add(label);
                  frame.pack();
                  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                  frame.setLocationRelativeTo(null);
                  frame.setVisible(true);
              });
          }
      }

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

              Created:
              Updated:
              Resolved: