I am trying to set my font for emacsclient like so:
(let ((default-font (cond
((member "Inconsolata" (font-family-list))
"Inconsolata 14")
(t
"monospace 20"))))
(set-default-font default-font)
(add-to-list 'default-frame-alist `(font . ,default-font)))
I C-x C-e
at the cond
sexp and it returns "Inconsolata 14"
. I C-x C-e
at the let
sexp and the font is updated.
When I launch emacs via
$ emacs
it works (the font is set to Inconsolata 14).
However when I launch the application via
$ emacsclient --alternate-editor="" --create-frame "$@"
the font is monospace 20 instead.
Please advise.
EDIT:
I have discovered that by including
(message "%s" (font-family-list))
in my .emacs file that (font-family-list)
returns nil
when emacsclient is starting up.
Unfortunately, also during initialization:
;; Both also print `nil` to the `*Messages*` buffer.
(message "%s" (find-font (font-spec :name "inconsolata")))
(message "%s" (find-font (font-spec :name "Inconsolata")))
;; Throws "error: No fonts being used"
(message "%s" (describe-font "Inconsolata"))
I do not know how to detect if a font is installed during initialization. My question has become: How do I reliably check whether a font is available when emacsclient starts up?
EDIT 2:
Echoing in after-init-hook
, emacs-startup-hook
, window-setup-hook
, before-make-frame-hook
, and after-make-frame-functions
also results in nil
.