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

Emoji rendering regression after JDK-8208377

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2 P2
    • 25
    • 25
    • client-libs
    • 2d

      The following example of emoji rendering doesn't work correctly after the changes in JDK-8208377 (Soft hyphens render if not using TextLayout).

      (The repro requires downloading the font from https://github.com/googlefonts/noto-emoji/blob/main/fonts/NotoColorEmoji-emojicompat.ttf to the working directory.)

      ```
      import java.awt.Font;
      import java.awt.font.FontRenderContext;
      import java.awt.font.GlyphVector;
      import java.nio.file.Files;
      import java.nio.file.Path;

      public final class T {

        private static final String WOMAN = "\ud83d\udc71\ud83c\udffd\u200d\u2640\ufe0f";
        private static final String ASTRONAUT = "\ud83d\udc69\ud83c\udffc\u200d\ud83d\ude80";
        private static final String FAMILY = "\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67";

        // https://github.com/googlefonts/noto-emoji/blob/main/fonts/NotoColorEmoji-emojicompat.ttf
        private static final Path font = Path.of("NotoColorEmoji-emojicompat.ttf");

        public static void main(String[] args) throws Exception {
          test(WOMAN);
          test(ASTRONAUT);
          test(FAMILY);
        }

        static void test(String text) throws Exception {
          GlyphVector glyphVector = getGlyphVector(text);
          if (glyphVector.getNumGlyphs() != 1) {
            throw new AssertionError();
          }
        }

        private static GlyphVector getGlyphVector(String text) throws Exception {
          FontRenderContext frc = new FontRenderContext(null, true, true);
          return Font.createFont(Font.TRUETYPE_FONT, Files.newInputStream(font))
              .layoutGlyphVector(frc, text.toCharArray(), 0, text.length(), Font.LAYOUT_LEFT_TO_RIGHT);
        }
      }
      ```

      $ java -fullversion
      openjdk full version "25-ea+16-1816"
      $ java T
      Exception in thread "main" java.lang.AssertionError
              at T.test(T.java:25)
              at T.main(T.java:17)

            dgredler Daniel Gredler
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: