There are two types of programmers in the world: those who care about programming font, and those who don’t concern themselves with typography. As a code producing entity, why would you even need to care about such things as fonts? Fonts are what designers agonize about – and they are probably more qualified to do it than we are. Especially those of us who are back-end hackers, producing most of our code in Vim or Emacs. Why should we care?
Well, it is a matter of convenience. The font your text editor uses to render your code has great impact on it’s readability. Understanding source code, unlike poetry or prose, hinges on exactness and clarity. Code can be cryptic, and tends to use symbols, numbers and letters in strange non-word combinations. Your eyes have to be able to recognize characters at a glance, without a pause.
Have you ever found yourself squinting at your screen and wondering whether a character is a “zero” or an upper case “O”? If yes, then you are using the wrong font for programming. This post is for you.
A good programming font requires a number of features. The most important feature is of course crisp clarity of the characters and monospaced layout. Funky serifs, or too aggressive kearning can lead to readability issues down the road. Fonts that look great on pages of a book won’t usually be good for programming.
Here is a list of things I would like to see in a “perfect” font:
- Dashed zeros – I need a big honking crossbar through my zeros. Fuck the tiny dots in the middle. I want a big dash.
- No base serifs on one’s. The font should have very sloping upper serif, and nothing on the bottom.
- Rounded lower case L’s – I don’t want to see any serifs on top, and the bottom should loop for clarity
- Big fucking top and bottom serifs on upper-case I so there is no way you could confuse it with vertical pipe
- Comma’s that look nothing like periods. There is nothing worse than missing the crucial difference between 1,001 and 1.001 or foo(bar.baz) and foo(bar,baz). I want the commas to have distinct shapes.
- Distinct quotes and backticks. Backticks should be very loopy so they are instantly recognizable.
Recently I polled people on Twitter, and in /code forum asking them what was their favorite programming font. I got bunch of good suggestions, and this post is an overview of all of these.
If you are a windows user, you are in luck. Despite a popular belief, there are some decent folks toiling away at Microsoft, and some of them have designed a really nice font that is damn near perfect for programming. Chances are you already have it installed on your system. If not, you can grab it from here.
Consolas looks great on the page. The zeros have the crossbars as they should, the colons are nicely rounded. The lower case “j” is nicely looped making it quite distinct from a lower case i and the lower case “g” is of the stacked variety (which has nothing to do with readability, but I personally like it). The ones and l’s are still not as distinct as I would like. The sloping upper serif on “1” looks flat on smaller font sizes. But all in all it is a great font.
It’s main flaw? It’s windows only.
Speaking of system exclusive fonts, Apple has something even better than Consolas – a font called Monaco.
It has all of the good features I mentioned liking in Consolas – a crossbar through the zero, nicely rounded semicolons, good spacing on quotations, looping j and etc… It also does a much better job at distinguishing l’s and one’s. Note how the serrifs on the letter “l” follow a zigzag pattern – upper serif only on the left, lower serif only on the right. Compare it to the sloping upper serif and flat base on 1. The two are still fairly close, but much easier to distinguish at smaller sizes.
Personally, I really like the look of the font. It is more rounded, and has that sort of whimsical, soft feel to it. It looks very pretty and stylish. Alas, that font is Mac only.
Droid Sans Mono
Quite a few people told me they like Droid Sans Mono, so lets check it out:
This is a font that does the L’s correctly. Note that the 1 has no base serif, removing almost all confusion in this area. Sadly, the upper case I is almost indistinguishable from the L. Also, there is no crossbar on the zero, introducing confusion elsewhere. In addition, the commas are a bit to straight for my taste. At smaller sizes they can be easily mistaken for periods. Not my favorite font, but a lot of people swear by it.
If you want a decent, open source font, Terminus is a viable choice:
One of the fatal flaws of Terminus is that it is a bitmap font. It does not scale well, so it only works at sizes less than 12-14. Any higher and you start to see ugly pixelation. The 1’s and l’s and I’s are handled rather poorly looking painfully similar. Commas and periods are tiny, and too samey. I’m also not a big fan of the blocky appearance of the font – though that’s just a matter of aesthetics.
Pro Font is a bitmap font, but it does a lot of things exactly right:
The number one, has a very large bottom base serif, whereas l has a tiny one. The large top and bottom serifs on upper case I make it distinct from both of these. Zeros are properly crossed as well. The best feature of this font are the commas and semicolons. Check out the huge dot of the comma versus the visibly smaller period. This is something that would probably drive a designer nuts, but as a programmer this is exactly what I want.
Anonymous Pro is actually quite similar to Pro Font, though in many ways it is prettier.
I really like the numbers in this font. The aggressive serifs give it character and personality, whereas most other monospaced fonts tend to be rather bland. In that it reminds me of Monaco which also has great aesthetic look, but Anonymous Pro is sharper and more edgy.
The one is very distinct due to the large top serif. The lowercase L and I are a bit to close for comfort. I do like the pointy, sloping commas that jag out quite a bit.
Inconsolata is one of my favorite fonts on this list, but it is nowhere near close to being perfect:
The one’s are quite distinct with the lack of the bottom bar, but I’s and l’s are still very, very close. Commas are definitely too small. The font does look nice though. It is close to Consolas (I think by design) and aims to create similar aesthetic feel, while being a little better at distinguishing certain fonts.
Monfour is a bizarre monstrosity. It is a monospaced font with the whimsy and subversive carelessness of comic sans. It is too loopy and radical for most people, but it does have some interesting qualities, which is why I included it here:
Note the rounded L’s that cannot be possibly mistaken for an upper case I, a vertical pipe or number one. The dotted zeros are not as distinct as ones with a cross bar, but they are there suggesting that this could be used as a programming font. The commas are small, but quite distinct from the tiny periods. All in all, it is not a bad font, especially if you feel like doing something different and you don’t mind the tilted e’s.
Unsurprisingly, there is no winner here. No font on this list has met all of my requirements. Many come close, but miss some very crucial details. Before I started this list, I was torn between Consolas, Inconsolata and Monaco all of which have their own pros and cons. Now I added Anonymous Pro to the list of fonts I’m on the fence about.
How about you? What is your favorite? Does a perfect font that would meet all my needs even exist? Let me know in the comments.