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.

Cheers,

Roy.

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
current."
  (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)
  (my/setup-frame))

Add

(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

(message
    (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

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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