Rework how unicode fonts are set and loaded
This commit is contained in:
parent
2525822791
commit
a4fb4070ea
3 changed files with 22 additions and 11 deletions
|
@ -68,7 +68,8 @@ See `doom|init-fonts'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when doom-font
|
(when doom-font
|
||||||
(set-frame-font doom-font t))
|
(set-frame-font doom-font t))
|
||||||
(doom|init-fonts))
|
(doom|init-fonts)
|
||||||
|
(mapc #'doom|init-emoji-fonts (frame-list)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/reload-theme ()
|
(defun doom/reload-theme ()
|
||||||
|
|
|
@ -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
|
It is recommended you don't set specify a font-size, as to inherit `doom-font's
|
||||||
size.")
|
size.")
|
||||||
|
|
||||||
(defvar doom-unicode-font nil
|
(defvar doom-unicode-font
|
||||||
"Fallback font for unicode glyphs. Is ignored if :ui unicode is active.
|
(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
|
It defaults to Apple Color Emoji on MacOS and Symbola on Linux. Expects either a
|
||||||
`doom-font' for examples.
|
`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
|
It is recommended you don't set specify a font-size, as to inherit `doom-font's
|
||||||
size.")
|
size.")
|
||||||
|
@ -464,10 +468,7 @@ Fonts are specified by `doom-font', `doom-variable-pitch-font',
|
||||||
(when doom-serif-font
|
(when doom-serif-font
|
||||||
(set-face-attribute 'fixed-pitch-serif nil :font doom-serif-font))
|
(set-face-attribute 'fixed-pitch-serif nil :font doom-serif-font))
|
||||||
(when doom-variable-pitch-font
|
(when doom-variable-pitch-font
|
||||||
(set-face-attribute 'variable-pitch nil :font 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)))
|
|
||||||
((debug error)
|
((debug error)
|
||||||
(if (string-prefix-p "Font not available: " (error-message-string e))
|
(if (string-prefix-p "Font not available: " (error-message-string e))
|
||||||
(lwarn 'doom-ui :warning
|
(lwarn 'doom-ui :warning
|
||||||
|
@ -475,6 +476,13 @@ Fonts are specified by `doom-font', `doom-variable-pitch-font',
|
||||||
(font-get (caddr e) :family))
|
(font-get (caddr e) :family))
|
||||||
(signal 'doom-error e)))))
|
(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)
|
(defun doom|init-theme (&optional frame)
|
||||||
"Load the theme specified by `doom-theme' in FRAME."
|
"Load the theme specified by `doom-theme' in FRAME."
|
||||||
(when (and doom-theme (not (memq doom-theme custom-enabled-themes)))
|
(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))
|
(add-hook 'doom-init-ui-hook #'doom|init-theme))
|
||||||
;; Apply `doom-font' et co
|
;; Apply `doom-font' et co
|
||||||
(add-hook 'doom-after-init-modules-hook #'doom|init-fonts)
|
(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
|
;; Setup `doom-load-theme-hook' and ensure `doom-theme' is always set to the
|
||||||
;; currently loaded theme
|
;; currently loaded theme
|
||||||
(advice-add #'load-theme :after #'doom*run-load-theme-hooks)
|
(advice-add #'load-theme :after #'doom*run-load-theme-hooks)
|
||||||
|
|
|
@ -163,7 +163,7 @@ Doom was setup, which may cause problems.")
|
||||||
(setq selection-coding-system 'utf-8)) ; with sugar on top
|
(setq selection-coding-system 'utf-8)) ; with sugar on top
|
||||||
|
|
||||||
(setq-default
|
(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
|
apropos-do-all t ; make `apropos' more useful
|
||||||
auto-mode-case-fold nil
|
auto-mode-case-fold nil
|
||||||
autoload-compute-prefixes 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
|
jka-compr-verbose doom-debug-mode ; silence compression messages
|
||||||
ffap-machine-p-known 'reject ; don't ping things that look like domain names
|
ffap-machine-p-known 'reject ; don't ping things that look like domain names
|
||||||
find-file-visit-truename t ; resolve symlinks when opening files
|
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
|
;; be quiet at startup; don't load or display anything unnecessary
|
||||||
inhibit-startup-message t
|
inhibit-startup-message t
|
||||||
inhibit-startup-echo-area-message user-login-name
|
inhibit-startup-echo-area-message user-login-name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue