Tuesday, April 10, 2007

Emacs and bitstream fonts

I use emacs on Ubuntu heavily and naturally want a nice font to use. I chose to use the "bitstream vera sans mono" font. Well, easy does it: Options->Customize Emacs->Specific Face: "default", and setting the value of "Font Family" to "bitstream-bitstream vera sans mono" and value of "Height" to "100" gave me the nice font that I wanted. "Custom" created the settings for me:


(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(default ((t (:inherit nil :stipple nil :background "gray12" :foreground "green" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 117 :width normal :family "bitstream vera sans mono")))))

I should mention that I am using the "color-scheme" package and using a nice looking color scheme. The color information probably comes from there.

But then I tried to create a new frame (C-x 5 2) and lo! the new frame had my old font. Reading the emacs faq gave the answer: I'd have to set the font again in the variable that determines the options for all new frames. So I set in my "~/.emacs":

(setq default-frame-alist
'((font . "-bitstream-bitstream vera sans mono-medium-r-normal--0-0-0-0-m-0-iso8859-1")))
and new frames would now have the specified font, which happens to be the same as the original. I wonder if it is a coincidence that the size of the font in new frames and initial matches, because I have not specified the height of the font in this variable.

This seems like a ugly way: why specify the font properties in two different places? So I commented out the face created by custom, and oops! new frames would have a background of white. So I had to undo the change and let the fonts be specified in two places. But at least the initial and new frames have the same good looking font.

No comments: