Finding, Selecting, and Managing TTF Programmer Fonts for X

I've had several disputes with friends over the years about the relative importance of the appearance of your computer environment, and I usually fall on the side of function over form. But the more time I spend coding, the more the appearance of the fonts I use matters to me. Once you become interested in the subject, you'll discover that "Programmer Fonts" are a really, really big deal on the Internet. What I hope to cover here is how to find, select, and manage fonts in an X Windows environment. I use Linux, but this may be applicable to *BSD as well(?).

The Old Way

For many years, I used default terminal fonts - right up until I discovered the Terminus font. Terminus is generally installable via an OS package: on Debian, it's xfonts-terminus. These days, most people are most familiar with True Type Fonts, but Terminus predates TTF. This would take us down an historic rabbit hole of how X Fonts were handled pre-TTF - not a fun pursuit, and perhaps a post for another day. Terminus is available as a TTF conversion, although I've had some problems with some of the characters looking a bit chunky (it tends to work better at the original set of sizes).

On Ubuntu 15.10 the command to start an xterm with a Terminus font is:

$ xterm -fn terminus-20 &

where the "-20" is the font size. This will of course only work if you have the Terminus font package installed. Or you can set the default font in ~/.Xdefaults (I'm not going to cover that). But on my 16.04 XUbuntu system I get a TTF font anyway with this command (Deja Vu Mono, I think). To actually get the old X Terminus, I have to override the use of TTF fonts:

$ xterm -fa "" -fn terminus-20 &

You can figure out the available non-TTF font sizes by taking a look at the aliases in /usr/share/fonts/X11/misc/fonts.alias - although that isn't an elegant solution. There's a graphical tool for that ... but you'll probably run back to parsing the fonts.alias file after you see it. Try the xfontsel command sometime if you want to see what the 80s were like in Unix.

True Type Fonts

TTF fonts aren't as simple to install and use on X as they are on Windows and Mac - although the way I do things may be old-fashioned and there may be a simpler solution. But the methods I'll explain do work.

You'll find that most conversations about "Programmer's Fonts" online are dominated by a relatively short list of recommended fonts - and most (not all) of these are available from the Powerline font repository ... with the added advantage that the fonts are already patched for Vim's Powerline/Airline plugins. They're all monospace. Put TTF fonts in ~/.fonts/ (you may have to create that folder). You may need to run fc-cache -f ~/.fonts/ (although my systems seem to notice and update these themselves now). To list the available fonts, run fc-list - the output is incredibly ugly, but it works.

One of the better sites to find the best font for you is Programming fonts, but any search for "best programmer fonts" will lead you to dozens of people offering advice - and usually screenshots of the fonts as well. Important things to look at are your vertical characters, the number one "1," the letter lower case "l," the pipe "|," and the letter upper case "I" (which look unfortunately similar in my blog's current webfont). Similarly, look closely at the three Os: zero "0," upper case "O," and lower case "o."

The font I've ended up using for the last year is "Droid Sans Mono Slashed for Powerline:" this is based on the Droid Sans Mono font, with a slashed zero and the font modified for Powerline. It's a very plain and innocuous font, and I like it for that: it doesn't say "look at me," it just ... shows you the characters in their plainest and most readable form.

Discovering http://s9w.io/font_compare/ led to me choosing a couple more fonts to test, and that led to my having to dig in to sort out the details and write this blog entry.