Contents

quest for anti aliased emacs

Contents

In contemplating a move back to Linux for my day job, or at least a future where more of my work is done directly on my Linux box, I began to pine for decent anti-aliased fonts for Emacs. Both the windows and mac builds of Emacs 22 have this support built-in. Although, good luck trying to figure out how to change the font to what you want, at least in Carbon Emacs. Fortunately the default font of Monaco is pretty good (albeit not perfect). I don’t have a lot of experience with EmacsW32, even though I do have it installed somewhere. At first, I was puzzled as to why Emacs just didn’t come with anti-aliased fonts on Fedora 7 by default. Some web searches led me to believe that support was to be merged in before Emacs 22.1, and there I was, running 22.1. Alas, I had misread the interweb. If support has been merged in, it has been merged in after 22.1. Since 22.1 is the latest stable version of Emacs (as of this writing), it isn’t all that surprising that Fedora 7 doesn’t have this. Ah, well, time to move to the bleeding edge. Concise instructions for building a CVS version of Emacs with anti-aliased fonts can be found on the XftGnuEmacs page. I didn’t have a whole lot of trouble building and installing this version, but what I really want is a Fedora 7 package to replace the delivered packages. If I were running Ubuntu, this wouldn’t be much of a problem. So far, my attempts to hack the existing source RPM for Emacs haven’t met with much success. It doesn’t help that emacs take a while to compile, and I keep having to completely start over. I’ll update this entry if I ever get an rpm built.

Update: I’ve managed to work through the major issues, so here is the source RPM for Fedora 7. I’ve put some actual binaries here. This version doesn’t replace the stock Emacs-22.1. Instead it installs into /usr/local, but can easily be made the default version via the alternatives command:

alternatives --set emacs /usr/local/bin/emacs-23.0.0

Now that I have a working version of Emacs with anti-aliased font support, I’ve been hunting down what font to actually use. Bitstream Vera Sans Mono is a good default, but at the moment I’m trying out Anonymous. For the curious, the bit of elisp that I’m using to set the fonts is this:

(if (eq window-system 'x)
    ;; if we have the Xft-enabled version of emacs...
    (if (>= emacs-major-version 23)
    (progn
      ;; note: Anonymous doesn't come with Fedora.  You can get it here:
      ;; http://www.ms-studio.com/FontSales/anonymous.html
      (set-default-font "Anonymous-10")
      (setq bvsm10 "Bitstream Vera Sans Mono-10")
      ;; unfortunately, anonymous doesn't have bold or italic
      ;; so, use bitstream vera sans mono for that
      (set-face-font 'bold (concat bvsm10 ":weight=bold"))
      (set-face-font 'italic (concat bvsm10 ":slant=oblique"))
      (set-face-font 'bold-italic
             (concat bvsm10 ":weight=bold:slant=oblique"))
      ;; ...and no proportional font, for that matter
      (set-face-font 'variable-pitch "Bitstream Vera Sans-10")
      (add-to-list 'default-frame-alist '(font . "Anonymous-10")))
      ;; otherwise...
      (progn
    (set-default-font
     "-*-lucidatypewriter-medium-r-*-*-14-140-*-*-*-*-*-*"))
      )
  )

I’m doing it this way (instead of in X resources) so that launching Emacs-22.1 will still work. If you stick with Bitstream Vera Sans Mono (or DejaVu LGC Sans Mono which is very similar), then you won’t have to bother with overriding the bold, italic, and bold-italic font settings as those will basically just work once you set the default font. You would still have to deal with overriding the proportional font, however.