Why does the following Skia code not render the emoji 💯 when run on https://fiddle.skia.org/?

195 views
Skip to first unread message

stephane

unread,
Jan 27, 2024, 4:20:13 PM1/27/24
to skia-discuss
I've been trying to render the "💯" emoji using Skia on the Skia Fiddle platform, but it's not displaying as expected. Here's the code snippet I'm using:

void draw(SkCanvas* canvas) {
    const char* fontFamily = nullptr;  // Default system family, if it exists.
    SkFontStyle fontStyle;  // Default is normal weight, normal width, upright slant.

    sk_sp<SkTypeface> typeface = fontMgr->legacyMakeTypeface(fontFamily, fontStyle);

    SkFont font1(typeface, 64.0f, 1.0f, 0.0f);
    SkPaint paint1;
    paint1.setAntiAlias(true);
    paint1.setColor(SkColorSetARGB(0xFF, 0x42, 0x85, 0xF4));

    canvas->clear(SK_ColorWHITE);
    canvas->drawSimpleText("été 💯", strlen("été 💯"),
                               SkTextEncoding::kUTF8, 20.0f, 64.0f, font1, paint1);
}

https://fiddle.skia.org/c/29711605f622144ce10fe89d95db1b52

The text "été" is rendered correctly, but the "💯" emoji is not showing up. What could be causing this issue, and how can I fix it to display the emoji correctly on Skia Fiddle? I have the same problem under my app that run under windows

Данил Буланов

unread,
Jan 28, 2024, 8:45:19 AM1/28/24
to skia-discuss
I suppose that you should provide emoji font in order to render it.

воскресенье, 28 января 2024 г. в 00:20:13 UTC+3, stephane:

stephane

unread,
Jan 29, 2024, 4:27:43 AM1/29/24
to skia-discuss
Thanks  Данил,

Yes, it seems that on Windows, I need to use 'Segoe UI Emoji' instead of 'Segoe UI'. But when I use the 'Segoe UI' font, isn't there a fallback mechanism to automatically switch to 'Segoe UI Emoji' when an emoji is encountered in the text?

Данил Буланов

unread,
Jan 29, 2024, 8:56:25 AM1/29/24
to skia-discuss
I am not sure how it will switch to 'Segoe UI Emoji' if you did not provide it (or did you?). In you demo you provide one font, and it seems to make sense that it does not render emoji, since that font dose not include emoji. I use SkParagraph, and it has option for passing fontFamilies which is a string array, and I pass several fonts (including separate emoji font), and fallback works as expected (it chooses the first font which has necessary character)
понедельник, 29 января 2024 г. в 12:27:43 UTC+3, stephane:

stephane

unread,
Jan 29, 2024, 12:48:15 PM1/29/24
to skia-discuss
yes, with  SkParagraph it's work well and i didn't need even to pass any font family to SkParagraph to show the emoji as all emojis are well printed. but with  SkParagraph quality of the text is not as good as with drawsimpletext :(

jlav...@google.com

unread,
Jan 29, 2024, 1:12:15 PM1/29/24
to skia-discuss
I think it's just the matter of selecting the right font. 
Reply all
Reply to author
Forward
0 new messages