Noto Color Emoji not rendering in Emacs

643 Views Asked by At

I can't get Emacs on X11 to display emojis using Google's Noto Color Emoji font. I'm testing with a file containing only one Unicode character CROSSED FLAGS (U+1F38C) and a line feed. I open this file using emacs -Q crossed-flags.txt to inhibit any customizations in my init file or elsewhere to get into the way.

The buffer displays a somewhat wider-than-usual white space where the crossed flags emoji would be expected:

Emacs displaying white space instead of emoji

Here's the excerpt from C-u C-x = on the emoji's position. Specifically the line starting with ftcrhb seems to indicate that everything is fine, from Emacs' perspective:

               script: emoji
               syntax: w    which means: word
             category: .:Base
             to input: type "C-x 8 RET 1f38c" or "C-x 8 RET CROSSED FLAGS"
          buffer code: #xF0 #x9F #x8E #x8C
            file code: #xF0 #x9F #x8E #x8C (encoded by coding system utf-8-unix)
              display: by this font (glyph code):
    ftcrhb:-NONE-Noto Color Emoji-regular-normal-normal-*-14-*-*-*-m-0-iso10646-1 (#xC95)

I've collected a Fontconfig trace to show where the font is loaded from using FC_DEBUG=1 emacs -Q crossed-flags.txt >emacs29-fc.log 2>&1. This contains the following info near the end, with file:... locations indicating that the font file of Noto Color Emoji could be found at the expected location.

Match Pattern has 28 elts (size 32)
    family: "Noto Color Emoji"(s) "DejaVu Sans"(w) "DejaVu LGC Sans"(w) "DejaVu LGC Sans"(w) "DejaVu Sans"(w) "Bitstream Vera Sans"(w) "Verdana"(w) "Arial"(w) "Albany AMT"(w) "Luxi Sans"(w) "Nimbus Sans L"(w) "Nimbus Sans"(w) "Helvetica"(w) "Lucida Sans Unicode"(w) "BPG Glaho International"(w) "Tahoma"(w) "Noto Sans CJK JP"(w) "Noto Sans CJK SC"(w) "Noto Sans CJK TC"(w) "Nachlieli"(w) "Lucida Sans Unicode"(w) "Yudit Unicode"(w) "Kerkis"(w) "ArmNet Helvetica"(w) "Artsounk"(w) "BPG UTF8 M"(w) "Waree"(w) "Loma"(w) "Garuda"(w) "Umpush"(w) "Saysettha Unicode"(w) "JG Lao Old Arial"(w) "GF Zemen Unicode"(w) "Pigiarniq"(w) "B Davat"(w) "B Compset"(w) "Kacst-Qr"(w) "Urdu Nastaliq Unicode"(w) "Raghindi"(w) "Mukti Narrow"(w) "malayalam"(w) "Sampige"(w) "padmaa"(w) "Hapax Berbère"(w) "MS Gothic"(w) "UmePlus P Gothic"(w) "SimSun"(w) "PMingLiu"(w) "WenQuanYi Zen Hei"(w) "WenQuanYi Bitmap Song"(w) "AR PL ShanHeiSun Uni"(w) "AR PL New Sung"(w) "MgOpen Modata"(w) "VL Gothic"(w) "IPAMonaGothic"(w) "IPAGothic"(w) "Sazanami Gothic"(w) "Kochi Gothic"(w) "AR PL KaitiM GB"(w) "AR PL KaitiM Big5"(w) "AR PL ShanHeiSun Uni"(w) "AR PL SungtiL GB"(w) "AR PL Mingti2L Big5"(w) "MS ゴシック"(w) "ZYSong18030"(w) "TSCu_Paranar"(w) "NanumGothic"(w) "UnDotum"(w) "Baekmuk Dotum"(w) "Baekmuk Gulim"(w) "KacstQura"(w) "Lohit Bengali"(w) "Lohit Gujarati"(w) "Lohit Hindi"(w) "Lohit Marathi"(w) "Lohit Maithili"(w) "Lohit Kashmiri"(w) "Lohit Konkani"(w) "Lohit Nepali"(w) "Lohit Sindhi"(w) "Lohit Punjabi"(w) "Lohit Tamil"(w) "Meera"(w) "Lohit Malayalam"(w) "Lohit Kannada"(w) "Lohit Telugu"(w) "Lohit Oriya"(w) "LKLUG"(w) "FreeSans"(w) "Arial Unicode MS"(w) "Arial Unicode"(w) "Code2000"(w) "Code2001"(w) "sans-serif"(w) "Roya"(w) "Koodak"(w) "Terafik"(w) "sans-serif"(w)
    familylang: "de"(s) "en-us"(w)
    stylelang: "de"(s) "en-us"(w)
    fullnamelang: "de"(s) "en-us"(w)
    slant: 0(i)(s)
    weight: 80(i)(s)
    width: 100(i)(s)
    size: 14.4(f)(s)
    pixelsize: 15(f)(s)
    spacing: 100(i)(s)
    foundry: "NONE"(s)
    hintstyle: 3(i)(s)
    hinting: True(s)
    verticallayout: False(s)
    autohint: False(s)
    globaladvance: True(s)
    file: "/usr/share/fonts/truetype/NotoColorEmoji-Regular.ttf"(s)
    index: 0(i)(s)
    scalable: True(s)
    charset: 
    0000: 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000
    0020: 00002000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    0e00: 00000000 03ff0000 00000000 87fffffe 00000000 00000000 00000000 00000000
(s)
    lang: "de"(w)
    fontversion: 2147483647(i)(s)
    embeddedbitmap: True(s)
    decorative: False(s)
    lcdfilter: 1(i)(w)
    namelang: "de"(s)
    prgname: "emacs-29.0.60"(s)
    symbol: False(s)

Best score 0 0 0 0 0 0 0 0 2000 1001 0 0 0 0 0 0 0 0 0 0 0 0 0 2.14742e+12
Pattern has 24 elts (size 24)
    family: "Noto Color Emoji"(w)
    familylang: "en"(w)
    style: "Regular"(w)
    stylelang: "en"(w)
    fullname: "Noto Color Emoji"(w)
    fullnamelang: "en"(w)
    slant: 0(i)(w)
    weight: 80(i)(w)
    width: 100(i)(w)
    spacing: 100(i)(w)
    foundry: "NONE"(w)
    file: "/usr/share/fonts/truetype/NotoColorEmoji-Regular.ttf"(w)
    index: 0(i)(w)
    outline: True(w)
    scalable: True(w)
    charset: 
    0000: 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000
    0020: 00002000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    0e00: 00000000 03ff0000 00000000 87fffffe 00000000 00000000 00000000 00000000
(w)
    lang: (w)
    fontversion: 65536(i)(w)
    capability: "otlayout:DFLT otlayout:latn"(w)
    fontformat: "TrueType"(w)
    decorative: False(w)
    postscriptname: "NotoColorEmoji"(w)
    color: False(w)
    symbol: False(w)

I've tried various fontconfig tweaks in $HOME/.config/fontconfig/conf.d, but none of them solved the problem. Hence, I've collected the above info with all fontconfig customizations moved out of the way as recommended in etc/PROBLEMS of the Emacs source distribution.

Any ideas on how this could be resolved?

1

There are 1 best solutions below

0
On

It turns out that this is a problem of the specific font file in my environment. When installing the font from the official Ubuntu package using sudo apt install fonts-noto-color-emoji, the emoji renders as expected:

Emoji rendered as expected in Emacs29 on Jammy

In contrast, most of the TTF file versions available directly from Noto Color Emoji GitHub repository result in rendering only white space, as illustrated in the OP. The only TTF file from GitHub that works as expected -on Ubuntu 22.04 (Jammy) at least- is NotoColorEmoji-emojicompat.ttf.

An interesting side note is that when compiling the identical Emacs version (from emacs-29 branch) on Ubuntu 16.04 (Trusty) and using the identical font version linked above, emojis are rendered black and white only.

I haven't investigated the source of this difference any further, but assume it is caused by older versions of some Emacs dependencies on Trusty, specifically freetype, fontconfig and/or cairo.

Emoji rendered black and white only in Emacs29 on Trusty