April 2nd, 2009

How to get nice, smooth, X11 fonts in your terminal and editors

We all know that bitmap fonts are great, but sometimes its nice to have some smoothing and anti aliasing to make things easier on the eyes. How is this accomplished? By adding this to your ~/.Xdefaults file:

Xft.hinting: true
Xft.hintstyle: hintslight
Xft.antialias: true
Xft.rgba: none
Xft.dpi: 96

If your using an LCD you can set Xft.rgba to rgba to do sub-pixel smoothing. Personally I don't like it, but it could just be the LCDs I'm using. Also, if the font your using supports different levels of hinting, you can change Xft.hintstyle to 'hintslight', 'hintsfull', 'hintsmedium', or 'hintsnone'. All fonts seem to do these differently, so you have to experiment a little bit.

After you change your ~/.Xdefaults, you have to merge it to your current running settings (or restart X, but who wants to do that). Merge your changes with 'xrdb -merge ~/.Xdefaults'. To set different fonts for individual programs, do something like:

Emacs.font: Inconsolata-10

or

urxvt*font: xft:Inconsolata:size=10

You may have to consult your program's man page or docs to see what style it wants the font string in. It seems that every program does it a little bit differently. Hope this was helpful, enjoy easy reading with smooth fonts! I'm using the awesome Envy Code R font in my terminal.