Emacs font settings not working in new frame

12

2

I'm trying to get comfortable with emacs. I installed emacs starter kit. Now I'm trying to customize fonts. In ~/.emacs.d/init.el I did (set-frame-font "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1"). It is working fine untill I do C-x 5 2. The new frame gets created with fonts, that were on the system before my customization. How do I override this behaviour to use only fonts I specify in init.el? Should I, probably, create ~/.emacs file for such settings (it's missing now)?

folone

Posted 2010-11-13T20:47:57.650

Reputation: 273

Answers

20

set-frame-font sets the font of the current frame. To set the default font for all frames, include the following line in your ~/.emacs.d/init.el, set the font parameter in default-frame-alist:

(add-to-list 'default-frame-alist
             '(font . "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1"))

~/.emacs is the traditional location for Emacs's configuration file. ~/.emacs.d/init.el is an alternate name with exactly the same role. Use either (but not both).

For X displays (i.e. on unix, or on non-unix systems using an X server), you can also set the font through X resources. On many systems, ~/.Xresources is read when you log in, and you can write there:

Emacs.font: -adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1

Gilles 'SO- stop being evil'

Posted 2010-11-13T20:47:57.650

Reputation: 58 319

Type M-x customize-option, enter Customize variable: default-frame-alist , click INS, enter Parameter: font and Value: "-outline-Droid Sans Mono-normal-normal-normal-mono-13-*-*-*-c-*-iso8859-1" (note surrounding " for font), click State and Save for Future Sessions – kwarnke – 2017-10-19T10:45:24.943

Congrats on the 10K. – Paused until further notice. – 2010-11-13T22:58:32.403

Yay, finally a working answer for this. set-default-font ...? No, that would be too simple! – Sam Watkins – 2012-10-02T04:44:09.387

6

set-frame-font takes two optional arguments: KEEP-SIZE and FRAMES. If FRAMES is set to a non-nil value then the font is applied to future frames.

(set-frame-font "Inconsolata-13" t t)

I'm not sure how long this has been the case, but it's true as of Emacs 24.4.1.

ohspite

Posted 2010-11-13T20:47:57.650

Reputation: 171