diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-06-01 08:52:59 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-06-01 08:52:59 -0700 |
commit | 322865563df37fc62f89f1fbd913e342859907d8 (patch) | |
tree | a4940b00774d3897e8c9f2459ca5fcc5094d6773 /.emacs.d | |
parent | 48698369b24c3cf2890fc2cbcc73f6fb5779a734 (diff) | |
download | dotfiles-322865563df37fc62f89f1fbd913e342859907d8.tar.gz |
fix setting fonts at startup
Diffstat (limited to '.emacs.d')
-rw-r--r-- | .emacs.d/init-spw.el | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/.emacs.d/init-spw.el b/.emacs.d/init-spw.el index 319bf22c..0ca7f30b 100644 --- a/.emacs.d/init-spw.el +++ b/.emacs.d/init-spw.el @@ -111,22 +111,31 @@ add places the library might be available to `load-path'." (car (seq-drop-while (lambda (font) (not (find-font (font-spec :name font)))) fonts))) -(when-let ((latin-font (spw/first-available-font spw/preferred-latin-fonts))) - (set-face-font 'default latin-font)) -(when-let ((han-font (spw/first-available-font spw/preferred-han-fonts))) - (dolist (charset '(kana han symbol cjk-misc bopomofo)) - (set-fontset-font t charset han-font))) - -;; again on laptop, need to fit a bit more in these windows than can -;; with Inconsolata (defun spw/select-cousine () (buffer-face-set (face-remap-add-relative 'default :family "Cousine" :height 100))) -(when (find-font (font-spec :name "Cousine-10")) - (dolist (pair '((org-mode . org-mode-hook) - (org-agenda-mode . org-agenda-mode-hook))) - (with-eval-after-load (car pair) - (add-hook (cdr pair) #'spw/select-cousine)))) +(defun spw/do-font-setup () + (remove-hook 'focus-in-hook #'spw/do-font-setup) ; harmless if hook absent + (when-let ((latin-font (spw/first-available-font spw/preferred-latin-fonts))) + (set-face-font 'default latin-font)) + (when-let ((han-font (spw/first-available-font spw/preferred-han-fonts))) + (dolist (charset '(kana han symbol cjk-misc bopomofo)) + (set-fontset-font t charset han-font))) + + ;; again on laptop, need to fit a bit more in these windows than can + ;; with Inconsolata + (when (find-font (font-spec :name "Cousine-10")) + (dolist (pair '((org . org-mode-hook) + (org-agenda . org-agenda-mode-hook))) + (eval-after-load (car pair) + `(add-hook ',(cdr pair) #'spw/select-cousine))))) + +;; `find-font' will fail until there is a graphical frame, which might +;; not be yet, so set up a hook (which will remove itself after +;; running once) to do the font setup +(if (daemonp) + (add-hook 'focus-in-hook #'spw/do-font-setup) + (spw/do-font-setup)) (when (fboundp 'set-scroll-bar-mode) (set-scroll-bar-mode nil)) (when (fboundp 'tool-bar-mode) (tool-bar-mode 0)) |