I want to set a default font in my Emacs (version 26.1, running on Arch, using Xmonad). I have tried various options in my init.el file (under .emacs.d). None seemed to work or persist when I restarted X.

The only thing that works and persists is specifying it in my .Xresources file, e.g. in my case Emacs.font: DejaVuSansMono-14

Is there a "standard" way of setting the default font in Emacs ? Is this it ? Is it dependent on the emacs version, i.e. this is the latest version 26.1

Thanks for any help.



  • 1
    Did you try setting the frame parameters using the default-frame-alist or the initial-frame-alist? gnu.org/software/emacs/manual/html_node/emacs/… – lawlist Oct 25 '18 at 13:44
  • Yes, but I will double check. If these are in init.el, do you not have anything in .Xresources ? – Hoopla Oct 25 '18 at 14:03

Try to add the following to your init.el file and change the font family and height to whatever you want.

(defun my/setup-frame (&optional frame)
  "Configure look of FRAME.

If FRAME is nil, configure current frame. If non-nil, make FRAME
  (when frame (select-frame frame))
  (when (window-system)
    (set-face-attribute 'default nil :height 125 :family "Fira Mono")))

(if (daemonp)
    (add-hook 'after-make-frame-functions #'my/setup-frame)


(set-frame-font "DejaVu Sans Mono-14" nil t)

to your init.el file. This would affect all frames (last parameter t).

If you're not sure about the font name, you can see a list of all available fonts by evaluating this

    (mapconcat (quote identity)
        (sort (font-family-list) #'string-lessp) "\n"))

in your *scratch* buffer. Check the output in your *Messages* buffer.

Other tips here.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.