From a4fb4070ead9847e3d742560dc2d6a8a8cd38cf4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 15 May 2019 20:22:27 -0400 Subject: [PATCH] Rework how unicode fonts are set and loaded --- core/autoload/config.el | 3 ++- core/core-ui.el | 26 ++++++++++++++++++-------- core/core.el | 4 ++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/core/autoload/config.el b/core/autoload/config.el index fd44686b8..ea943d333 100644 --- a/core/autoload/config.el +++ b/core/autoload/config.el @@ -68,7 +68,8 @@ See `doom|init-fonts'." (interactive) (when doom-font (set-frame-font doom-font t)) - (doom|init-fonts)) + (doom|init-fonts) + (mapc #'doom|init-emoji-fonts (frame-list))) ;;;###autoload (defun doom/reload-theme () diff --git a/core/core-ui.el b/core/core-ui.el index ab59d95d2..5105d1736 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -38,11 +38,15 @@ Expects either a `font-spec', font object, a XFT font string or XLFD string. See It is recommended you don't set specify a font-size, as to inherit `doom-font's size.") -(defvar doom-unicode-font nil - "Fallback font for unicode glyphs. Is ignored if :ui unicode is active. +(defvar doom-unicode-font + (if IS-MAC + (font-spec :family "Apple Color Emoji") + (font-spec :family "Symbola")) + "Fallback font for unicode glyphs. -Expects either a `font-spec', font object, a XFT font string or XLFD string. See -`doom-font' for examples. +It defaults to Apple Color Emoji on MacOS and Symbola on Linux. Expects either a +`font-spec', font object, a XFT font string or XLFD string. See `doom-font' for +examples. It is recommended you don't set specify a font-size, as to inherit `doom-font's size.") @@ -464,10 +468,7 @@ Fonts are specified by `doom-font', `doom-variable-pitch-font', (when doom-serif-font (set-face-attribute 'fixed-pitch-serif nil :font doom-serif-font)) (when doom-variable-pitch-font - (set-face-attribute 'variable-pitch nil :font doom-variable-pitch-font)) - ;; Fallback to `doom-unicode-font' for Unicode characters - (when (fontp doom-unicode-font) - (set-fontset-font t nil doom-unicode-font nil 'append))) + (set-face-attribute 'variable-pitch nil :font doom-variable-pitch-font))) ((debug error) (if (string-prefix-p "Font not available: " (error-message-string e)) (lwarn 'doom-ui :warning @@ -475,6 +476,13 @@ Fonts are specified by `doom-font', `doom-variable-pitch-font', (font-get (caddr e) :family)) (signal 'doom-error e))))) +(defun doom|init-emoji-fonts (frame) + "Set up unicode fonts (if `doom-unicode-font' is set). + +By default, this uses Apple Color Emoji on MacOS and Symbola on Linux." + (when doom-unicode-font + (set-fontset-font t '(#x1F600 . #x1F64F) doom-unicode-font frame 'prepend))) + (defun doom|init-theme (&optional frame) "Load the theme specified by `doom-theme' in FRAME." (when (and doom-theme (not (memq doom-theme custom-enabled-themes))) @@ -510,6 +518,8 @@ Fonts are specified by `doom-font', `doom-variable-pitch-font', (add-hook 'doom-init-ui-hook #'doom|init-theme)) ;; Apply `doom-font' et co (add-hook 'doom-after-init-modules-hook #'doom|init-fonts) +;; Ensure unicode fonts are set on each frame +(add-hook 'after-make-frame-functions #'doom|init-emoji-fonts) ;; Setup `doom-load-theme-hook' and ensure `doom-theme' is always set to the ;; currently loaded theme (advice-add #'load-theme :after #'doom*run-load-theme-hooks) diff --git a/core/core.el b/core/core.el index c6a07890a..b4050b176 100644 --- a/core/core.el +++ b/core/core.el @@ -163,7 +163,7 @@ Doom was setup, which may cause problems.") (setq selection-coding-system 'utf-8)) ; with sugar on top (setq-default - ad-redefinition-action 'accept ; silence advised function warnings + ad-redefinition-action 'accept ; silence redefined function warnings apropos-do-all t ; make `apropos' more useful auto-mode-case-fold nil autoload-compute-prefixes nil @@ -171,7 +171,7 @@ Doom was setup, which may cause problems.") jka-compr-verbose doom-debug-mode ; silence compression messages ffap-machine-p-known 'reject ; don't ping things that look like domain names find-file-visit-truename t ; resolve symlinks when opening files - idle-update-delay 2 ; update ui less often + idle-update-delay 2 ; update ui slightly less often ;; be quiet at startup; don't load or display anything unnecessary inhibit-startup-message t inhibit-startup-echo-area-message user-login-name