46

I can't set Inconsolata as default font in Emacs 24.4 Linux.

  • I changed the font in the menu -> Save options. The font changed but after a restart the font is the same as it was by default.

  • Added this to ~/.Xresources: Emacs.font: Inconsolata LGC

    Then in init.el: (set-default-font "Inconsolata LGC"). Same story.

What I'm doing wrong?

Maglight
  • 643
  • 1
  • 5
  • 6
  • If the font works when you set it, but is gone again the next time you load emacs, this might be a problem with where your customize settings are (or aren't) getting saved to. – nispio Oct 23 '14 at 16:12
  • 1
    I use emacsclient with emacs started as a daemon. I change settings in init.el and after saving restart the daemon. – Maglight Oct 23 '14 at 16:33
  • 2
    Is this specific to Emacs 24.4? IOW, do you get different behavior in another build/release? If not, consider removing the reference to 24.4. – Drew Oct 23 '14 at 16:39
  • Since you are starting emacs as a daemon, inspect all of the console output from your call to `emacs --daemon` and make sure that there are no error messages. – nispio Oct 23 '14 at 17:38
  • 1
    I have this in my `init.el`: (set-frame-font "Ubuntu Mono 11") – thdox May 13 '15 at 18:53
  • Xah Lee has a great page on the subject http://ergoemacs.org/emacs/emacs_list_and_set_font.html – Toon Claes Jun 26 '19 at 10:00

6 Answers6

40

I have the following in my .emacs using Emacs for OSX:

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 130 :width normal :family "Inconsolata")))))

Setting the font

It's easiest to set the font using the menus if you're running Emacs in a graphical environment. Use "Options -> Set Default Font..." from the menus.

Now, you're not done because you've only changed the font temporarily. The easiest method that I know of is to use the customization mode.

M-x customize-face RET default RET

Now change the options you wish to change, if any. If you've already changed the font using the menus, you should see your changes here.

Saving to your init file

Save For Future Sessions by either:

  • Click on the State button and choose Save For Future Sessions

or

  • C-x C-s while in the Customization buffer which will should do the same thing but doesn't always work, e.g. after (set-default-font "Inconsolata")

If all else fails...

You may have luck with the Set Fonts page.

Harvey
  • 978
  • 6
  • 15
32

I use this in my init.el:

;; Set default font
(set-face-attribute 'default nil
                    :family "Source Code Pro"
                    :height 110
                    :weight 'normal
                    :width 'normal)

You could try the same using Inconsolata instead of Source Code Pro.

Boccaperta-IT
  • 1,556
  • 11
  • 24
  • Added it in init.el. After restart still font by default. – Maglight Oct 23 '14 at 15:56
  • Have you typed "InconsolataLGC" without the blank space between "Inconsolata" and "LGC"? – Boccaperta-IT Oct 23 '14 at 16:01
  • Yes, I also tried to set it to Terminus. – Maglight Oct 23 '14 at 16:07
  • 1
    Try running ```fc-cache -fv``` from your terminal. Maybe font cache is not up-to-date. I tried setting Anonymous Pro and it works on mine. – Boccaperta-IT Oct 23 '14 at 16:10
  • Thanks, but that didn't help. I can set this font, but Emacs doesn't save it in future sessions. – Maglight Oct 23 '14 at 16:15
  • Check your ```custom-set-variables``` and ```custom-set-faces``` in your init file. There should be anything in there regarding your font setting if you are using the code snippet I provided above. – Boccaperta-IT Oct 23 '14 at 16:21
  • Nothing at all. I removed this sections from init.el and inserted font setting at the beginning of the file. – Maglight Oct 23 '14 at 16:27
  • You should add this snippet after loading your theme. Or you could **M-x** `customize-face` RET, `default` RET, change the `height` and click _Apply and Save_ – caisah Oct 23 '14 at 17:41
  • Why after loading the theme? In my init.el I load the theme after that snippet. – Boccaperta-IT Oct 23 '14 at 17:49
  • @Boccaperta-IT Yeah, you're right. I thought if you load the theme after `custom-set-faces` will override the these settings. But the precedence of `custom-set-faces` seems to be higher. – caisah Oct 24 '14 at 05:56
  • removing .emacs.desktop from ~ helps if you are under linux – Filip Górny Nov 13 '15 at 08:47
  • `(set-face-attribute 'default nil :font "Source Code Pro Medium 12")` works fine here. – ideasman42 Jun 14 '19 at 13:06
14

If you changed something in .Xresources file then you need to reread it to see any changes in current session.

  • To keep your old resources settings and apply new one:

    xrdb -merge ~/.Xresources
    
  • To throw away your old resources and apply only settings from .Xresources:

    xrdb ~/.Xresources
    

Adjustments in .Xresources file are better, because they are applied before mapping emacs' X11 window. Customizations in init files (.emacs, .emacs.d/) are re-applied to already created window. You can for example avoid toolbars "flickering" during startup when you add

! UI elements
Emacs.menuBar: 0
Emacs.toolBar: 0
Emacs.verticalScrollBars: off
! Font settings
Emacs.FontBackend: xft,x
Emacs.font: Inconsolata LGC:size=16

to your .Xresources file.

You can check what else is available at https://www.gnu.org/software/emacs/manual/html_node/emacs/X-Resources.html

kmicu
  • 2,395
  • 1
  • 15
  • 15
8

From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html#Fonts

Add a line to your init file:

(add-to-list 'default-frame-alist
             '(font . "DejaVu Sans Mono-10"))
rchar01
  • 437
  • 4
  • 8
7

This always works whenever I want to try other fonts (put it in your init.el or .emacs file):

(push '(font . "Inconsolata") default-frame-alist)

or

(add-to-list 'default-frame-alist '(font . "Inconsolata"))

In this case both expressions are equivalent.

In short, these forms set the font for the current and all future Emacs frames. Since these are saved in your configuration file, the setup is not lost on restart.

undostres
  • 1,793
  • 12
  • 15
1

All I did after setting my font with Options/Set Default Font... was Options/Save Options and it saved it to my .emacs, and it worked.

Vercingatorix
  • 201
  • 1
  • 6