最近遇到一个奇怪的问题,同样的 doom font 配置在 Arch 和 Mac 上都能运行,但是在特定的某台 Arch 上面就会出错。已确定所有的字体都已经安装了。
配置如下:
(when (display-graphic-p)
(cond (IS-MAC
(setq doom-font (font-spec :family "Iosevka Term Light" :size 18)
doom-big-font (font-spec :family "Iosevka Term Light" :size 24)
doom-modeline-height 32) )
(IS-LINUX
(setq resolution-factor (eval (/ (x-display-pixel-height) 1080.0)))
(setq doom-font (font-spec :family "Iosevka Term" :size (eval (round (* 14 resolution-factor))) :weight 'light)
doom-big-font (font-spec :family "Iosevka Term" :size (eval (round (* 20 resolution-factor))))
doom-modeline-height (eval (round (* 32 resolution-factor))))))
参考了: GitHub - ztlevi/doom-config: Blazing fast Doom Emacs private configuration
目前只在一台特定的 Arch 上能复现。
--debug-init
的报错:
(doom-private-error "+ui.el" (user-error "‘doom-font’ must be set to a valid font"))
signal(doom-private-error ("+ui.el" (user-error "‘doom-font’ must be set to a valid font")))
可以确定所提到的 Iosevka Term
字体是安装了的。
cireu
2019 年11 月 23 日 03:43
3
用rg全局搜索了一下这个error,只发现一个地方
;;;###autoload
(defun doom/reload-font ()
"Reload your fonts, if they're set.
See `doom-init-fonts-h'."
(interactive)
(doom-init-fonts-h 'reload))
;;;###autoload
(defun doom/increase-font-size (count &optional increment)
"Enlargens the font size across the current and child frames."
(interactive "p")
(doom-adjust-font-size (* count (or increment doom-font-increment))))
;;;###autoload
(defun doom/decrease-font-size (count &optional increment)
"Shrinks the font size across the current and child frames."
(interactive "p")
(doom-adjust-font-size (* (- count) (or increment doom-font-increment))))
;;;###autoload
在这里只要doom-font变量不为nil就会直接通过,不报错
另外有
(defvar IS-LINUX (eq system-type 'gnu/linux))
那么结论可能有
变量IS-LINUX或者system-type再特定机器由于特定原因被清除了,导致doom-font没有被正常赋值
用了假Arch
cireu
2019 年11 月 23 日 03:44
4
(when (display-graphic-p)
(cond (IS-MAC
(setq doom-font (font-spec :family "Iosevka Term Light" :size 18)
doom-big-font (font-spec :family "Iosevka Term Light" :size 24)
doom-modeline-height 32) )
(IS-LINUX
(setq resolution-factor (eval (/ (x-display-pixel-height) 1080.0)))
(setq doom-font (font-spec :family "Iosevka Term" :size (eval (round (* 14 resolution-factor))) :weight 'light)
doom-big-font (font-spec :family "Iosevka Term" :size (eval (round (* 20 resolution-factor))))
doom-modeline-height (eval (round (* 32 resolution-factor))))))
没有必要使用eval,你不会以为eval是用来做数值计算的吧。
顺带一提(/ (x-display-pixel-height) 1080)
就会得到没有小数点的除法结果。然后你下面也不需要用round了
在custom.el中 加入自己的配置,config.el 中注释掉font的系统配置,添加下面的配置,支持 Source Code Variable Italic:
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won’t work right.
'(default ((t (:family “Source Code Variable” :foundry “ADBO” :slant italic :weight normal :height 173 :width normal)))))