vicfryzel

Better fonts in your terminal, vim, etc

If you're like me and you spend all day staring at text on a screen, there are numerous things you consider important. Of those things, readability is paramount. I've adopted a favorite configuration of fonts that I find so beneficial that I thought I'd share. Here, I'll discuss the Envy Code R font and how to make it good on an LCD monitor.

I run Arch Linux, so I'll describe how to do everything here in Arch, but most of it is applicable to other distros. Before we begin, we'll be using some packages out of the AUR, so your first step is to install packer, an AUR helper.

wget http://aur.archlinux.org/packages/packer/packer.tar.gz
tar -xzvf packer.tar.gz
cd packer
makepkg
# The following may be slightly different if the version changes
sudo pacman -U packer-20100622-1-any.pkg.tar.xz </pre>

There are many programming fonts to choose from. My favorite is Envy Code R, but yours might be different. Here are some popular fonts you can choose from that all have AUR packages:

For some really good font reviews, see Hivelogic and thatwebguyblog.

Once you've settled on a font that you like, install it with the following command, replacing the package name as appropriate.

sudo packer -S ttf-envy-code-r

Fire up your terminal and select your new font. If you use gnome-terminal, that means right click on your terminal, select Profiles > Profile Preferences, click on the button next to Font:, and select your new font. On a 1680x1050 LCD, I find the ideal size for Envy Code R is 10pt regular. In gnome-terminal, you should see the font change immediately after hitting OK.

You might be thinking "it's a little fuzzy." If so, it's because anti-aliasing is turned on, and you don't want it turned on for a programming font like this. This is pretty quick and easy to fix. The following steps are taken from the Arch Linux Font Configuration Guide. Skip this step if you're on a CRT.

sudo pacman -Rd libxft cairo
sudo packer -S fontconfig-lcd cairo-lcd
sudo pacman -S libxft-lcd

Now that we've got LCD patched packages installed, let's disable anti-aliasing for our new font.

mkdir ~/.fonts.conf.d
vim 10-no-aa-envy-code-r.conf

In the file 10-no-aa-envy-code-r.conf, paste the following XML and save.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
  <test name="family">
    <string>Envy Code R</string>
  </test>
  <edit name="antialias" mode="assign">
    <bool>false</bool>
  </edit>
  <edit name="hinting">
    <bool>false</bool>
  </edit>
</match>
</fontconfig>

If you're not using Envy Code R, replace as appropriate with something like "Inconsolata-g" or "Droid Sans Mono". Be warned, Inconsolata-g looks bad without anti-aliasing, at least on my screen.

Once the file is there, restart your terminal, and voila: you should have no more fuzziness.

Let me know your favorite fonts and configurations, I'm always looking to improve my setup!

Example of Envy Code R

Comments