Picking the perfect font for writing code.

Programmers use a lot of tools throughout the day. Some of them are pretty obvious: a fast PC, wide monitor (or three), a robust IDE, and good coffee. Other items tend to get overlooked a bit more often: a quality keyboard, top-notch chair, and natural lighting. However, the most underappreciated tool of all is the proper font.

Many designers know that understanding typography is an important element in enhancing usability. Using the proper typeface increases both reading speed and reduces fatique. [1] (PDF) So, why do so many developers just use the default system fonts? Writing a résumé in Word is certainly a different data entry task than matching up curly brackets and double-checking for semicolons for 8+ hours at a time. Different task, different tool. Unhappy with Lucida Sans’ similiar looking 0’s and O’s and Courier’s barely-visible punctuation, I decided to hunt down the perfect font for writing code.

First, my “must haves”:

  • It must be monospaced and legible at smaller-than-normal font sizes.
  • Must be slightly more compressed than most monospaced fonts, which tend to be unusually wide.
  • Zeros must be easily descernable from the letter “O”. Ditto for the digit “1” and lowercase “L”‘s.
  • Punctuation marks must have some weight to them. I hate squinting at my monitor trying to figure out if a character is a comma or a period.
  • Single and double quotation marks must be surrounded by some white-space so I can tell them apart when using nested quotes.

The “would be nice” list:

  • Preferably free (as in beer), bonus points if it’s free (as in libre).
  • I’m primarily a Windows guy on the desktop, but it would be nice if the font is portable in case that ever changes–especially if I have to pay for it.
  • A good, extended character-set for those rare cases in which I’m editing/reading source written by someone in a foreign language. (Or when I use words like résumé)

Font Finding Fun

I spent almost a full day combing the web, looking for fonts that matched my criteria. I discovered that there are actually quite a few other programmers out there who have sought out a better font (see the links at the bottom of this post). In fact, there are even fonts designed solely with the coder in mind. After trying about a half a dozen of these, I settled on Bitstream Vera Sans Mono.

Bitstream Vera Sans Mono 8pt

Bitstream Vera Sans Mono 8pt

Bitstream Vera Sans Mono 6pt

Bitstream Vera Sans Mono 6pt

I found that Bitstream Vera Sans Mono met all of my mandatory requirements, and all but one optional criterion. The font has the standard Latin diacritics, but is missing support for Cyrillic, Arabic and other non-Western characters. But since it’s free (in both sense of the word), I can easily overlook it. The font is completely usable at 8pt, and still legible even at 6pt. Quotation marks are nicely offset, and zeros have the requsite dot in the center.

A close second was ProFont, which seems to have it’s own fan club. But after a trial run I found it a bit too lightweight for my tastes.

While my coding productivity hasn’t drastically increased since using Bitstream Vera Sans Mono, I have noticed that I squint less and make fewer mistakes when working with nested quotes. My code also just plain seems easier to read. Though I’m sure that actually adding comments would improve readability even moreso. 😉

Other resources