From 54e8577bf60bd7dbd89527ad5f28d80ab7584c04 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 18 Sep 2018 22:48:21 -0400 Subject: [PATCH] Simplify doom|init-fonts: add xft font support custom-set-faces is somewhat overkill for this. It overwrites any user customizations for the default & variable-pitch faces, and saves them to custom-file, which may cause those settings to persist even when we don't want them to. This new solution is a little faster, is more respective of customizations, and adds XFT font string support. XFT font strings are a little more powerful. For example, the :antialias font-spec property was unreliable, but now you can use: (setq doom-font "Fira Mono:pixelsize=12:antialias=off") --- core/core-ui.el | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/core-ui.el b/core/core-ui.el index ed573188f..90d8f3781 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -307,17 +307,21 @@ frame's window-system, the theme will be reloaded.") (defun doom|init-fonts () "Initialize fonts." (condition-case e - (custom-set-faces - (when (fontp doom-font) - (let ((xlfd (font-xlfd-name doom-font))) - (add-to-list 'default-frame-alist (cons 'font xlfd)) - `(fixed-pitch ((t (:font ,xlfd)))))) - (when (fontp doom-variable-pitch-font) - `(variable-pitch ((t (:font ,(font-xlfd-name 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) - nil)) + (progn + (when doom-font + (add-to-list + 'default-frame-alist + (cons 'font + (cond ((stringp doom-font) doom-font) + ((fontp doom-font) (font-xlfd-name doom-font)) + ((signal 'wrong-type-argument (list '(fontp stringp) doom-font))))))) + (when (fontp doom-variable-pitch-font) + (set-face-attribute 'variable-pitch t + :width 'normal :weight 'normal :slant 'normal + :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) (if (string-prefix-p "Font not available: " (error-message-string e)) (lwarn 'doom-ui :warning