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")
This commit is contained in:
parent
b76a09539c
commit
54e8577bf6
1 changed files with 15 additions and 11 deletions
|
@ -307,17 +307,21 @@ frame's window-system, the theme will be reloaded.")
|
||||||
(defun doom|init-fonts ()
|
(defun doom|init-fonts ()
|
||||||
"Initialize fonts."
|
"Initialize fonts."
|
||||||
(condition-case e
|
(condition-case e
|
||||||
(custom-set-faces
|
(progn
|
||||||
(when (fontp doom-font)
|
(when doom-font
|
||||||
(let ((xlfd (font-xlfd-name doom-font)))
|
(add-to-list
|
||||||
(add-to-list 'default-frame-alist (cons 'font xlfd))
|
'default-frame-alist
|
||||||
`(fixed-pitch ((t (:font ,xlfd))))))
|
(cons 'font
|
||||||
(when (fontp doom-variable-pitch-font)
|
(cond ((stringp doom-font) doom-font)
|
||||||
`(variable-pitch ((t (:font ,(font-xlfd-name doom-variable-pitch-font))))))
|
((fontp doom-font) (font-xlfd-name doom-font))
|
||||||
;; Fallback to `doom-unicode-font' for Unicode characters
|
((signal 'wrong-type-argument (list '(fontp stringp) doom-font)))))))
|
||||||
(when (fontp doom-unicode-font)
|
(when (fontp doom-variable-pitch-font)
|
||||||
(set-fontset-font t nil doom-unicode-font nil 'append)
|
(set-face-attribute 'variable-pitch t
|
||||||
nil))
|
: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)
|
((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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue