Emoji's not rendering in Linux

Skip to first unread message

Jon Bell

Apr 5, 2024, 10:39:18 AMApr 5
to skia-discuss

I've been struggling to get color emojis rendering on Ubuntu 20.04 (via WSL). I'm trying to use the Noto Color Emoji font, but they do not show up. I found an old conversation from 2017  that sounds like a similar issue (https://groups.google.com/g/skia-discuss/c/1uJoMAvUXXo/m/k_zta3OYAAAJ) , but the Skia API has changed quite a bit since then, so I'm not sure what else I need to do. I made a similar test app that reproduces the problem that looks like this:

#include "include/core/SkBitmap.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkImage.h"
#include "include/core/SkCanvas.h"
#include "include/codec/SkEncodedImageFormat.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkStream.h"

#include "include/encode/SkJpegEncoder.h"

#include "include/ports/SkFontMgr_empty.h"
#include "include/core/SkFontMgr.h"
#include "include/core/SkFont.h"

int main() {

SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeS32(640, 480, kPremul_SkAlphaType));
SkCanvas canvas(bitmap);
SkPaint paint;

canvas.drawRect(SkRect::MakeXYWH(0, 0, 640, 480), paint);

  sk_sp<SkFontMgr> mgr = SkFontMgr_New_Custom_Empty();
  sk_sp<SkTypeface> emojiFace = mgr->makeFromFile("NotoColorEmoji-Regular.ttf");
SkString familyName;
SkDebugf("Emoji Family name: %s\n", familyName.c_str());

//replace "GT-America-Standard-Regular.otf" with other local font file
sk_sp<SkTypeface> face = mgr->makeFromFile("GT-America-Standard-Regular.otf");
//OR just use a default empty font face
//const char* fontFamily = nullptr;  // Default system family, if it exists.
    //SkFontStyle fontStyle;  // Default is normal weight, normal width, upright slant.

    //sk_sp<SkTypeface> face = mgr->legacyMakeTypeface(fontFamily, fontStyle);

SkDebugf("Non-Emoji Family name: %s\n", familyName.c_str());

const char text[] = "Skia";
const char emojiText[] = "A😌😀😬😁😂😃A";


SkFont font;


SkFont emojiFont;

SkPaint emojiPaint;


SkFILEWStream output("test.jpg");
SkPixmap pixmap;
auto opts = SkJpegEncoder::Options{};
    opts.fQuality = 90;
    if (canvas.peekPixels(&pixmap)) {
if (!SkJpegEncoder::Encode(&output, pixmap, opts)) {
SkDebugf("Cannot write output\n");
SkDebugf("Wrote image\n");
    } else {
        SkDebugf("Cannot readback on surface\n");

return 0;

I'm pointed to the current latest commit in the github mirror of the Skia code (8ad03dfe4e2eea42ddded1df0d38613b329a2095) and am building skia with the following commands:
gn gen out/so --args="is_component_build=true is_debug=true"
ninja -C out/so skia

then compiling my test app (from one directory up from the skia directory) like this:
c++ emoji_test.cpp -g -o emoji_test -std=c++17 -Iskia -Lskia/out/so/ -lskia -Wl,-rpath skia/out/so -DSK_SAMPLES_FOR_X

It doesn't look like SK_SAMPLES_FOR_X is recognized anymore, but I left it in. Note that you'll need to put NotoColorEmoji-Regular.ttf in the same directory as the executable and another font file (I was using GT-America) will also need to be added to the non-emoji test string.

It may also be worth noting that I first noticed this issue while using SKParagraph to lay out text including emojis, but this is the simplest reproduction case I could make. Thank you for any help/

Ben Wagner

Apr 5, 2024, 10:55:42 AMApr 5
to skia-d...@googlegroups.com
If your NotoColorEmoji-Regular.ttf is the newer COLRv1 version (and
not the older CBDT version) then your version of FreeType must be new
enough to support that format. The system FreeType in Ubuntu 20.04
(Version 2.10.1 it looks like) is much too old to support COLRv1 and
unfortunately the COLRv1 version of Noto Color Emoji has no outlines
to fall back to (every glyph is blank if the color version of the
glyph cannot be used). You can build using Skia's copy of FreeType
(with gn arg skia_use_system_freetype2=false) but then you just get
some random new version of FreeType that Skia uses for testing (with
upsides and downsides).
> --
> You received this message because you are subscribed to the Google Groups "skia-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/8a8ecae3-d68d-4233-b6b9-1a29e8e33ebcn%40googlegroups.com.

Jon Bell

Apr 5, 2024, 12:55:50 PMApr 5
to skia-discuss
Thank you for your response, I was aware that there were different color font formats but didn't know that the version of FreeType could be incompatible with COLRv1 fonts. The version of NotoColorEmoji-Regular.ttf I was using was from here https://fonts.google.com/noto/specimen/Noto+Color+Emoji downloaded a couple days ago, so I assume it is the newer COLRv1 version.
At your suggestion, I tried building skia with `skia_use_system_freetype2=false` and it looks like it is bundling version 2.13.2 (that's what I see in skia/externals/freetype/CMakeLists.txt, and it looks like this is the latest version), but I'm still not getting any color emojis rendered. I also tried `NotoColorEmoji.ttf` and `NotoColorEmoji_WindowsCompatible.ttf` from here: https://github.com/googlefonts/noto-emoji/tree/main/fonts which according to the commit messages should be CBDT format, but they don't seem to work either. Are there other dependencies or build configuration options that could be a problem for color font rendering?
Reply all
Reply to author
0 new messages