ChangeFontsPermanentlyOnWindows

Emacs 23

Use the menu:

This saves the font to .emacs.

Optionally, you can add some code to init.el directly:

(set-face-attribute 'default nil :font "Andale Mono-12")

or this, which works quite well for Emacs on Windows:

(set-face-attribute 'default nil :family "Consolas" :height 110)

For older Emacs-versions

Automatic

Lisp:frame-restore.el will save/restore the font you’ve selected through the mouse-set-font menu. this means you never have to know the “X format” name. very handy if you change the font often.

Manual

The problem is that you need to use the X format of specifying a font. Here’s how to do it (works with recent versions of Gnu-Emacs (Oct.2007)):

For even older Emacs-versions

(these are earlier guidelines on this page)

 From: Michael Slass <mikesl@wrq.com>
 Subject: Re: How to make selected font permanent?
 Newsgroups: gnu.emacs.help
 Date: Tue, 23 Oct 2001 19:22:39 GMT
  1. Set the font to what you like with s-down-mouse-1
  2. Figure out what that font is called
    1. switch to the scratch buffer
    2. enter “(frame-parameters)” without the quotes
    3. place the cursor after the closing paren and hit C-j
    4. a list of frame parameters will appear in the buffer. Look for something in the list like: (font . “-outline-Courier New-normal-r-normal-normal-16-120-96-96-c-100-iso8859-1”)
  3. copy the font form from the scratch buffer, and then add this to your .emacs (notice the added ‘ before the font form you just copied): (add-to-list ‘default-frame-alist ‘(font . “-outline-Courier New-normal-r-normal-normal-16-120-96-96-c-100-iso8859-1”))

The next time you start emacs, you’ll have the font you want.

Even simpler is just to evaluate (press C-x C-e at the end of the line):

(insert (prin1-to-string (w32-select-font)))

It will show you a dialog, from which you can choose font, and insert its name at the current point.

Discussion


With Emacs >= 21.x you can do it like: (set-face-font ‘default “-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-15”) in your .emacs


Sorry, but this does not work for me using GNU Emacs 21.2 on Windows XP. I can only see this:

((display . “”) (visibility . t) (icon-name) (window-id . “917794”) (top . 0) (left . 0) (buffer-list #<buffer scratch> #<buffer NEWS>

  1. <buffer Minibuf-1> #<buffer Customize Faces>) (unsplittable) (minibuffer . #<window 4 on Minibuf-0>) (modeline . t) (width . 80) (height . 40) …)

but not any kind of font information. Any hints?

Evaluating (frame-parameters) on recent versions gets you a truncated result (hence the three dots at the end), so it’s no longer a useful way of finding out the current font name. --MichaelMason
I’m sure there’s a prettier way to do this in elisp but you can find the font information by pasting this in the scratch buffer, putting the TextCursor at the end, and hitting C-j: (let (r) (mapcar (lambda (e) (if (eq (car e) ‘font) (push e r))) (frame-parameters)) r) – JDC
Simplest way that i always do is just do M-x set-face-font RET default RET .. now you get the list of the fonts that can be recognized by emacs.. something like -outline-XXX.. Select the one you want, C-k C-g and then paste it in for the default-frame-alist.. --GirishB
Another way is to type “(frame-parameter nil ‘font)” without the quotes to the scratch buffer and hit C-j.
You can display the full set of parameters for the current frame by evaluating (prin1-to-string (frame-parameters)). – MichaelMason
A pretty printing version of the above: (pr-to-string (frame-parameters)). – Yamitai
You can display a list of the available fonts by evaluating (prin1-to-string (x-list-fonts “*”)). – MichaelMason

Note: when you use the “change buffer font” menu, the font selected doesn’t affect the frame. Examine the buffer-face-mode-remapping variable for that using C-h v buffer-face-mode-remapping. – Yamitai

You can see the available fonts, and the effect each has, by cycling through them with command `doremi-font+’ in library doremi-frm.el. – DrewAdams


If you would like emacs to start with a specific font, instead of jumping around as it resizes, you can put your font configuration in the MsWindowsRegistry (and frame size):

[HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs]
"Emacs.FONT"="-*-Lucida Console-normal-r-*-*-11-82-96-96-c-*-iso8859-1"
"Emacs.GEOMETRY"="90x60"

– Dmb

But how about fontset? Is there any way to define fontset even before emacs starts? – JoonhwanLee


CategoryFaces CategoryCustomize