Config: Detect (and warn about) missing fonts

This commit is contained in:
TEC 2021-03-21 18:27:47 +08:00
parent 50fd782ac3
commit ab28913178
Signed by: tec
GPG Key ID: 779591AFDB81F06C
1 changed files with 49 additions and 1 deletions

View File

@ -724,6 +724,54 @@ aspects are nice, but on others I prefer Fira.
#+attr_html: :class invertible :alt Screenshot of the fonts within Emacs.
[[https://tecosaur.com/lfs/emacs-config/screenshots/font-face.png]]
In addition to these fonts, Merriweather is used with =nov.el=, and Alegreya as a
serifed proportional font used by =mixed-pitch-mode= for =writeroom-mode= with Org
files.
Because we care about how things look let's add a check to make sure we're told
if the system doesn't have any of those fonts.
#+name: detect-missing-fonts
#+begin_src emacs-lisp :tangle no
(defvar required-fonts '("JetBrainsMono.*" "Overpass" "JuliaMono" "IBM Plex Mono" "Merriweather" "Alegreya"))
(defvar available-fonts
(delete-dups (or (font-family-list)
(split-string (shell-command-to-string "fc-list : family")
"[,\n]"))))
(defvar missing-fonts
(delq nil (mapcar
(lambda (font)
(unless (delq nil (mapcar (lambda (f)
(string-match-p (format "^%s$" font) f))
available-fonts))
font))
required-fonts)))
(if missing-fonts
(pp-to-string
`(add-hook! 'doom-init-ui-hook
(run-at-time nil nil
(lambda ()
(message "%s missing the following fonts: %s"
(propertize "Warning!" 'face '(bold warning))
(mapconcat (lambda (font)
(propertize font 'face 'font-lock-variable-name-face))
',missing-fonts
", "))
(sleep-for 0.5)))))
";; No missing fonts detected")
#+end_src
#+begin_src emacs-lisp :noweb no-export
<<detect-missing-fonts()>>
#+end_src
This way whenever fonts are missing, after Doom's UI has initialised, a warning
listing the missing fonts should appear for at least half a second.
**** Theme and modeline
~doom-one~ is nice and all, but I find the ~vibrant~ variant nicer. Oh, and with the
nice selection doom provides there's no reason for me to want the defaults.
@ -8063,7 +8111,7 @@ export to a PDF.
(propertize "Success!" 'face '(bold success))
(propertize "doom sync" 'face 'font-lock-keyword-face)))
(sleep-for 1))))
"")
";; No missing LaTeX packags detected")
#+end_src
#+begin_src emacs-lisp :noweb no-export