Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a default font (Inconsolata) in my .emacs.el in Ubuntu?

I tried following the advice gathered from Google searches but I am not able to get it to work. My ~/.emacs.el file contains the following:

;; Set color scheme
(require 'color-theme)
(load-file "/home/manoj/Dropbox/conf/themes/color-theme-chocolate-rain.el")
(color-theme-chocolate-rain)

;; Set font
;; (set-default-font "-unknown-Inconsolata-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1")

;; Insert four spaces on tab
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)

I've commented out the font configuration line as it doesn't work. I'm using GNU Emacs 23.1.50.1 (i486-pc-linux-gnu, GTK+ Version 2.18.0) of 2009-09-27 on palmer, modified by Debian on Ubuntu Karmic.

like image 589
Manoj Govindan Avatar asked Oct 18 '10 10:10

Manoj Govindan


People also ask

How do I change the default font in Emacs?

Go to Options -> Set Default Font... . After you choose a font, don't forget to press Options -> Save Options —otherwise your new font will not be saved after you close Emacs.

What is the default font in Emacs?

By default, Emacs displays text on graphical displays using a 10-point monospace font, and the font size can be changed interactively (see Text Scale).

How do I find my Emacs font?

For a given character, you can find out which font was used by moving point to that character than then doing C-u C-x = which will give you all kinds of information about that position in the buffer, including which font was used for it.

How do you change the font on Spacemacs?

Another way is to use the key sequence "SPC z x" and then press "+/=" key to increase font size or "-" key to decrease font size. Other options are shown on the which-key menu. This effects only the present buffer. By the way, you can customize the step size via the variable text-scale-mode-step .


1 Answers

Judging from the emacs version, it appears you've installed emacs-snapshot (good).

So this should work:

sudo apt-get install ttf-inconsolata

Then put in your ~/.emacs file something like

(set-frame-font "Inconsolata-12")

(The 12 refers to the font size, and can be changed.)

like image 75
unutbu Avatar answered Oct 03 '22 00:10

unutbu