14

I have this line in my init.el file to set the size of the font in all frames:

(push '(font . "DejaVu Sans Mono-10") default-frame-alist)

It works but i'd like to have a bigger font in all buffers while keeping a smaller one for the mode line (so it could fit more information and be less distracting). The idea is to have this set automatically without having to change the font size with C-x C-+ for every open buffer.

I'm using Emacs 25.0.50.1 compiled from trunk on a GNU/Linux system.

Edit: just added an answer showing how it can be done.

14

Try replacing the code for setting the font size with this:

(set-face-attribute 'default nil :font "DejaVu Sans Mono-14")
(set-face-attribute 'mode-line nil :font "DejaVu Sans Mono-10")

Of course, you'll want to change the sizes (14 and 10) to values of your liking.


If you want to customize a specific face and don't know the name of it, try doing

M-x list-faces-display RET

This will give you a list of all faces (with previews) that you can search for specific keywords.

  • 1
    Thank you, that was it. The list-faces-display function prove to be very useful since there are 5 mode-line related faces which can be modified. – undostres Oct 10 '14 at 21:23
  • @undostres You're welcome :) – itsjeyd Oct 10 '14 at 21:55
  • Is there a way to specify the font relative to the default theme? Specifying a specific font size stops the font from scaling when using text-scale-increase/decrease – jr0cket Aug 15 '15 at 19:30
7

Thanks to the answer provided by itsjeyd I managed to write a short expression to change the size of all mode-line related faces for all current and future frames.

If you're using other themes besides the default one (such as zenburn, etc.), the code should be put after you've declared the theme; i.e., after this line:

(load-theme 'solarized-light t)

Assuming your default font size is other than 10, the code would be:

(let ((faces '(mode-line
               mode-line-buffer-id
               mode-line-emphasis
               mode-line-highlight
               mode-line-inactive)))
     (mapc
      (lambda (face) (set-face-attribute face nil :font "DejaVu Sans Mono-10"))
      faces))

For a smaller font, set a smaller value ("DejaVu Sans Mono-9"). Other fonts can be used: inconsolata, etc.

Edit: added a screenshot showing the results. The font size on the mode-line is 10 while the rest (buffers, etc.) is 12.

Smaller mode-line font

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.