Only init fonts once, and for any (tty/gui) session

This commit is contained in:
Henrik Lissner 2018-03-22 19:32:00 -04:00
parent 87f18bb906
commit 9f2a94c25a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -440,29 +440,27 @@ character that looks like a space that `whitespace-mode' won't affect.")
(defun doom|init-fonts (&optional frame) (defun doom|init-fonts (&optional frame)
"Initialize fonts." "Initialize fonts."
(add-hook 'after-make-frame-functions #'doom|init-fonts)
(when (fontp doom-font) (when (fontp doom-font)
(map-put default-frame-alist 'font (font-xlfd-name doom-font))) (map-put default-frame-alist 'font (font-xlfd-name doom-font)))
(when (display-graphic-p) (or frame (setq frame (selected-frame)))
(or frame (setq frame (selected-frame))) (condition-case-unless-debug ex
(condition-case-unless-debug ex (progn
(progn (when (fontp doom-font)
(when (fontp doom-font) (set-face-attribute 'fixed-pitch frame :font doom-font))
(set-face-attribute 'fixed-pitch frame :font doom-font)) ;; Fallback to `doom-unicode-font' for Unicode characters
;; Fallback to `doom-unicode-font' for Unicode characters (when (fontp doom-unicode-font)
(when (fontp doom-unicode-font) (set-fontset-font t 'unicode doom-unicode-font frame))
(set-fontset-font t 'unicode doom-unicode-font frame)) ;; ...and for variable-pitch-mode:
;; ...and for variable-pitch-mode: (when (fontp doom-variable-pitch-font)
(when (fontp doom-variable-pitch-font) (set-face-attribute 'variable-pitch frame :font doom-variable-pitch-font)))
(set-face-attribute 'variable-pitch frame :font doom-variable-pitch-font))) ('error
('error (if (string-prefix-p "Font not available: " (error-message-string ex))
(if (string-prefix-p "Font not available: " (error-message-string ex)) (lwarn 'doom-ui :warning
(lwarn 'doom-ui :warning "Could not find the '%s' font on your system, falling back to system font"
"Could not find the '%s' font on your system, falling back to system font" (font-get (caddr ex) :family))
(font-get (caddr ex) :family)) (lwarn 'doom-ui :error
(lwarn 'doom-ui :error "Unexpected error while initializing fonts: %s"
"Unexpected error while initializing fonts: %s" (error-message-string ex))))))
(error-message-string ex)))))))
(defun doom|init-theme () (defun doom|init-theme ()
"Set the theme and load the font, in that order." "Set the theme and load the font, in that order."