iqbalansari / emacs-emojify

Display emojis in Emacs
GNU General Public License v3.0
411 stars 40 forks source link

How to use color emoji font (ttf) instead of png files? #92

Closed ianyepan closed 3 years ago

ianyepan commented 3 years ago

First off, thanks for the great effort! emojify-insert-emoji is a brilliant command that I've been using more and more often.

On Emacs 27+, there is real color emoji font support, and I have been using the "Segoe UI Emoji" font in Emacs to displays emojis. In other words, emojify-mode doesn't even need to be enabled. In fact, I'm using emacs-emojify mainly for "insert" and "describe at point" purposes.

FYI, the snippet to specify the real colored emoji font in Emacs 27+ is as follows:

(set-fontset-font t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend)

The problem I have now is that emojify-insert-emoji shows a preview of emojis in the style "emojione-v2.2.6-22", as controlled by the variable emojify-emoji-set. This is a list of PNG files that is inconsistent with the style of "Segoe UI Emoji", which I use to display in my actual editing buffers.

My question is:

How can I set emojify-emoji-set to recognize the "Segoe UI Emoji" font (TTF) and show the previews in the Segoe style instead?

Here's a screenshot to explain the inconsistency. The green arrow points to the Segoe UI Emoji style (which I prefer), while the light-orange arrow points to emacs-emojify's "emojione-v2.2.6-22" style (which I'd like to replace).

image

mch commented 3 years ago

Have you tried setting emojify-emoji-style to '(unicode) and emojify-display-style to 'unicode? Here's the relevant settings from my config:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(emojify-display-style 'unicode)
 '(emojify-emoji-styles '(unicode)))

This is on a linux system using Noto Color Emoji: image

ianyepan commented 3 years ago

This is the perfect solution! Thank you very much, Matt! @mch

For the people looking for an answer, this is the complete snippet I'm using:

(use-package emojify
  :config
  (when (member "Segoe UI Emoji" (font-family-list))
    (set-fontset-font
     t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend))
  (setq emojify-display-style 'unicode)
  (setq emojify-emoji-styles '(unicode))
  (global-set-key (kbd "C-c .") #'emojify-insert-emoji))

And, voila!

image