diff --git a/docs/faq.org b/docs/faq.org index 97f95aa0b..480ae45a0 100644 --- a/docs/faq.org +++ b/docs/faq.org @@ -248,6 +248,8 @@ Doom exposes a couple variables for setting fonts. They are: - [[var:doom-variable-pitch-font]]: used for non-monospace fonts (e.g. when using variable-pitch-mode or mixed-pitch-mode). Popular for text modes, like Org or Markdown. +- [[var:doom-emoji-font]]: used for rendering emoji. Only needed if you want to use + a font other than your operating system’s default. - [[var:doom-symbol-font]]: used for rendering symbols. - [[var:doom-serif-font]]: the sans-serif font to use wherever the [[face:fixed-pitch-serif]] face is used. diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index 1762e1b8a..b3867e851 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -46,6 +46,14 @@ font to that size. It's rarely a good idea to do so!") (define-obsolete-variable-alias 'doom-unicode-font 'doom-symbol-font "3.0.0") +(defvar doom-emoji-font nil + "Fallback font for emoji. +Must be a `font-spec', a font object, an XFT font string, or an XLFD string. See +`doom-font' for examples. + +WARNING: if you specify a size for this font it will hard-lock any usage of this +font to that size. It's rarely a good idea to do so!") + (defvar doom-emoji-fallback-font-families '("Apple Color Emoji" "Segoe UI Emoji" @@ -525,15 +533,16 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (custom-push-theme 'theme-face face 'user 'set new-specs) (put face 'face-modified nil)))) (when (fboundp 'set-fontset-font) - (let ((fn (doom-rpartial #'member (font-family-list)))) - (when-let (font (cl-find-if fn doom-symbol-fallback-font-families)) + (let* ((fn (doom-rpartial #'member (font-family-list))) + (symbol-font (or doom-symbol-font + (cl-find-if fn doom-symbol-fallback-font-families))) + (emoji-font (or doom-emoji-font + (cl-find-if fn doom-emoji-fallback-font-families)))) + (when symbol-font (dolist (script '(symbol mathematical)) - (set-fontset-font t script font))) - (when-let (font (cl-find-if fn doom-emoji-fallback-font-families)) - (set-fontset-font t 'emoji font))) - (when doom-symbol-font - (dolist (script '(symbol mathematical)) - (set-fontset-font t script doom-symbol-font))) + (set-fontset-font t script symbol-font))) + (when emoji-font + (set-fontset-font t 'emoji emoji-font))) ;; Nerd Fonts use these Private Use Areas (dolist (range '((#xe000 . #xf8ff) (#xf0000 . #xfffff))) (set-fontset-font t range "Symbols Nerd Font Mono")))