Default fonts with emacsclient/emacs --daemon
I've been using set-default-font
in my .emacs
file to configure emacs to use my favorite programming font.
(set-default-font "Droid Sans Mono Slashed-10") ;;; set default font
I use emacs --daemon
to keep an instance of emacs running as a background process on my development machine so that I can run emacsclient
to call up an emacs window (frame) instantaneously (and keep the same session running even after a close the emacs frame).
Suddenly (after an aptitude safe-upgrade
, I think, but I'm not sure what triggered this change), emacs frames that are created by emacsclient
connecting to the emacs --daemon
instance no longer used my default font when initially opened. The default font worked properly for stand-alone emacs instances (opened with emacs
), and for emacsclient
, executing (set-default-font)
after startup worked fine, but it no longer worked automatically.
To fix this, I had to set up a default-frame-alist
, which I believe defines commands to execute whenever a new frame is opened.
(set-default-font "Droid Sans Mono Slashed-10") ;;; set default font
(setq default-frame-alist '((font . "Droid Sans Mono Slashed-10"))) ;;; set default font for emacs --daemon / emacsclient
By the way, I also discovered the describe-font
elisp function while trying to diagnose this issue.
(describe-font "Droid Sans Mono Slashed-10")
;; or M-x describe-font <RETURN> Droid Sans Mono Slashed-10 <RETURN>
which opens a *Help*
buffer containing:
name (opened by): -unknown-Droid Sans Mono Slashed-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1
full name: Droid Sans Mono Slashed:pixelsize=13:foundry=unknown:weight=normal:slant=normal:width=normal:spacing=100:scalable=true
size: 13
height: 17
baseline-offset: 0
relative-compose: 0