My fonts setup is
(setq default-frame-alist '((font . "DejaVu Sans Mono-10")))
(defun my-emoji-fonts ()
(set-fontset-font t 'symbol "Twemoji")
(set-fontset-font t 'symbol "Noto Color Emoji" nil 'append)
(set-fontset-font t 'symbol "Symbola" nil 'append))
(if (daemonp)
(add-hook 'server-after-make-frame-hook #'my-emoji-fonts)
(my-emoji-fonts))
With it most emoji display nice and coloured, except those for which DejaVu provides its own glyph, then that overrides the coloured one. How can I avoid that?
U+1F682 and U+2615. They don't let me sleep :/
describe-char
reports that the train is displayed with ftcrhb:-GOOG-Twemoji-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1 (#x3C6)
, while the coffee uses ftcrhb:-PfEd-DejaVu Sans Mono-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1 (#xA6C)
.
Solution
Turned out to be more complicated than I had thought. First, I had to turn off use-default-font-for-symbols
in order to make Emacs honor the fontsets. (I use the first person because I don't feel like saying "do this and that". I got it working by trial and error.) This allows an Emoji font to override the default one when both provide glyphs for the same character:
(setq use-default-font-for-symbols nil)
Now however all greek letters, mathematical symbols and so on had switched to Twemoji or Symbola. I didn't want that, so I what I had to do was
- restore DejaVu Sans Mono as the main symbols font;
- make Twemoji override DejaVu for some specified character ranges;
- finally, make Symbola act like a font of last resort.
The only arrangement of set-fontset-font
with which I was able to pull it off is this:
(defun my-emoji-fonts ()
(set-fontset-font t 'unicode (face-attribute 'default :family))
(set-fontset-font t '(#x2300 . #x27e7) "Twemoji")
(set-fontset-font t '(#x2300 . #x27e7) "Noto Color Emoji" nil 'append)
(set-fontset-font t '(#x27F0 . #x1FAFF) "Twemoji")
(set-fontset-font t '(#x27F0 . #x1FAFF) "Noto Color Emoji" nil 'append)
(set-fontset-font t 'unicode "Symbola" nil 'append))
I chose the range from #x2300
to #x1FAFF
but had to break it in correspondence of #x27e8
and x27e9
(i.e. ⟨ and ⟩) because I noticed that Symbola was overriding those two specific characters, though they are available in DejaVu Sans Mono. Thanks zzkt and rpluim for helping me out.