How to change Emacs' default font on Windows

What bugged me the most about Emacs when I started with it was that there was no easy way to permanently change my default font. Options -> Set Font and then Options -> Save Options would save my choices just for the session.

Then I realised that I have to do something to my .emacs file. But I didn't know what. Or why! Or even where to find such a .emacs file.

Emacs is a very customizable editor, you can tweak it in many many many different ways to suit your needs. I won't go on more about why Emacs rocks, that's for another post someday.

This recipe is about changing the default Emacs font.

1) Start Emacs (d'oh). We first get the name of the font; the way Emacs sees it.

2) Press C-x C-b and select *scratch*

3) In the *scratch* buffer, type in:
(w32-select-font)
and at the end of the line press C-j

4) You will get a Font Selection Dialog. Select the font you want. Click OK.

5) You should see a string similar to this:
"-raster-Dina-normal-r-normal-normal-13-97-96-96-c-*-iso8859-1"
Instead of Dina you'll see the selected font.

6) Now we open up your .emacs file and put this in. Press C-x C-f

7) In the mini-buffer, type in:
~/.emacs

8) If you are a newbie, a blank buffer will open up as you don't have a .emacs file.

9) Type in:
(set-default-font )
The above line calls a function called set-default-font that needs to be given an argument.

10) In my case it will be:
(set-default-font "-raster-Dina-normal-r-normal-normal-13-97-96-96-c-*-iso8859-1")

11) Remember to close the parenthesis. Press C-x C-s to save.

12) Press C-x C-c to close Emacs. When you restart Emacs you will see your chosen font as the default font.

Read this if you want to know more about why fonts in Emacs are named the way they are.