tags:

views:

1092

answers:

2

I recently declared .emacs bankrupcy and reorganized my init stuff. In the process, I ripped out all the hacky font selection stuff I had accrued over the years, figuring there are probably easier ways to accomplish what I want in the most modern version of emacs.

GNU Emacs 23.0.91.1 (i686-pc-linux-gnu, GTK+ Version 2.14.4)
on a GNU/Linux System (Ubuntu 8.10).

Let's ignore, for the moment, the fact that I also run emacs under Mac OS X (GUI+Terminal) and occasionally on Windows and just focus on the X11 case:

(Background: The font 6x13 has been part of X11 for as long as I can remember. (a.k.a misc-fixed semi-condensed ...). It's a bitmap font.)

  • I want emacs to always use the X11 bitmap font 6x13. (This gives me two buffers next to eachother on my netbook.)
  • I don't want to see DejaVu Sans Mono 16pt or whatever the heck comes up by default on my netbook (it's huge!)
  • I want every new frame and window to use this font.
  • I want derived faces (like org-mode-column) to use 6x13 font and not mysteriously switch back to DejaVu Sans Mono
  • I don't care what GNOME and X11 think the logical DPI of my screen is. I want 6x13.
  • When I remote into my netbook (NX Machine) I don't want to see 6x10. I want 6x13.
  • In case there's any doubt: I want 6x13.

What's the canonical way to do to make this happen?

And before some smart-aleck tells me about menu: Options>>Set Default Font: the resulting dialog box doesn't even offer bitmap fonts, so there's no way to choose 6x13. Furthermore, it doesn't solve the problem with org-mode: table-views still come up with the wrong font.

+3  A: 

You want to set the default frame parameters in your .emacs.

  • find out the name of the font you want to use
  • add the needed value to the default-frame-alist.

The easiest way, actually, is to use customize and customize default-frame-alist, but can also use elisp and write

(setq default-frame-alist 
   '(font . "-*-*-medium-r-normal--16-*-*-*-*-*-fontset-hiramin_w6"))

That's stolen from my emacs, you'll need to find the full font name (xfontsel?) for the font you want.

See also the EmacsWiki on setting fonts and faces.

Charlie Martin
+6  A: 

I control this stuff from my .Xresources file.

Personally I have

emacs.reverseVideo:     true
emacs.font:             7x13bold

(And I quite agree... long live the bitmap fonts! I'll take my xterm with

XTerm*foreground:       green
XTerm*background:       black
XTerm*font:             7x13bold

... over the Gnome terminal any day).

If you're playing with .Xresources from within a session, xrdb command is useful to reload them.

timday
This does exactly what I want. It even fixes the uglyness I was having with maximus and emacs interacting. (Maximus would maximize the window, while elisp code in my .emacs shrank the font -> large window, with small active area scrunched in the upper left.)
bendin
Thanks also for mentioning xrdb. That saved me much "why isn't this working" head-scratching. (It's been about 10 years since I last touched .Xresources...)
bendin