26

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?

  • 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
  • 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
  • I have this in my init.el: (set-frame-font "Ubuntu Mono 11") – thdox May 13 '15 at 18:53
25

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.

12

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.

  • 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
12

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

5

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.

4

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"))

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.