-
Bug
-
Resolution: Unresolved
-
P2
-
25
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)
(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)
- caused by
-
JDK-8208377 Soft hyphens render if not using TextLayout
-
- Resolved
-
- links to
-
Review(master) openjdk/jdk/24412