As I mentioned in a previous article, choosing a font involves determining first what the intended use is and then figuring out which typeface meets all the desired characteristics. After finding a typeface that satisfies your requirements, you choose one based on aestethic and personal preference.
Choosing a font for your editor or IDE requires following the same process.
As motivation, look at the following line of code
and tell me if
i is being initialized to
0. Does the loop stop
Programming is hard enough that you don’t want your programming font making it harder by having confusing glyphs.
Let’s examine the characteristics we want out of a programming font.
Criteria for Choosing a Good Programming Font
These are my criteria for choosing a good programming font. Any typeface that meets these criteria will work fine.
The history of programming makes monospaced typefaces a requirement. What is a monospaced typeface? It’s one where all the characters (glyphs) are the same width.
There is no fundamental reason why you couldn’t use a variable‑width font for programming, but since the art of programming comes from a time in which terminals didn’t have a graphic mode, we got used to using indentation to convey structure.
Indentation as structure works better with monospaced fonts.
Clear differentiation between problematic glyphs
Certain glyphs are easily confused and commonly used in computer languages. For example,
It’s a good idea to type that sequence of characters in your chosen typeface and make sure there is no ambiguity between those glyphs.
Syntax highlighting has become a common and often necessary element of editors and IDEs. Sometimes you can find small problems when you notice your editor didn’t change the color of a keyword or changed the style of a string.
If your editor’s theme relies on bold or italic styles, make sure that the typeface you select has those styles.
Remember that just slanting a typeface for italics, or using heavy lines for bold does not result in a typeface that’s easy to read.
For certain applications, it’s desirable to have a typeface that remains readable when used at small sizes.
One example is when you are debugging problems by looking at logs. It’s convenient to reduce the size of the typeface as much as you can, while it still remains readable, so that you can fit more text in the screen.
Survey of Programming Fonts
Armed with the simple criteria from the previous section, I surveyed the monospace typeface landscape and commented on each typeface. I also include a sample of the typeface so you can decide if you like it or not. I also include links to where you can get the font if you decide you like it.
If you don’t feel like choosing, use Incosolata. That’s what I use.
Bitstream Vera Sans Mono
Bitstream Vera Sans Mono is the monospaced typeface of the Vera family, designed by Jim Lyles in 2002. It has a very liberal license which allows it to be included in most Linux distributions as part of the Gnome desktop environment.
It’s a very good programming font with clear glyphs and very little room for confusion. In 2003, it was redesigned to provide better hinting at small sizes and have tighter line spacing.
You can get all of the fonts from the Vera family for free from here.
Consolas is a font commissioned by Microsoft when they started giving a shit about typography. That was roughly in 2006 with ClearType. It’s a typeface designed by Luc de Groot, who also designed Calibri (replacing the infamous Arial as the default typeface for Microsoft Office).
Consolas is so good that the makers of BBEdit licensed it for including it with their editor for OS X.
One of the big advantages of Consolas is that it has italic, bold, and bold‑italic styles in addition to the regular style.
I like Consolas a lot. It would easily be my favorite font if it wasn’t for the funky question mark.
If you have Windows you already have it, and you can use it without buying a license. If you are on OS X and have a copy of Microsoft Office, you also have it and are allowed to use it. Otherwise, you can buy Consolas for $49 per style (or $149 for all styles) here.
Inconsolata is an open source font designed by Ralph Levien. It draws its inspiration from Consolas. When Inconsolata was released, it didn’t have italic or bold styles, but when it was added to Google Fonts it gained a bold variant. It still has no italics so if your syntax‑highlighting style uses italic, you might not be able to use it.
Inconsolata is my favorite programming font and the one I use everywhere.
Droid Sans Mono
When Google bought Android, it released them with a very liberal Open Source license.
Droid Sans Mono has a fatal flaw in my opinion: the glyphs for “
and “O” are easily confused.
If you still want it, you can download it from here.
Hack is an Open Source font designed by Chris Simpkins in 2015. It’s very interesting because it’s not just very liberally licensed, the source code for the font is also open source. You can hack on it (geddit? Hack on it).
If Hack had a double‑story lowercase ‘g’, I’d probably switch to it (I have a thing for double‑story g’s). I remain hopeful that someone will add a variant with a double‑story ‘g’ and then I’ll switch from Inconsolata.
You can download Hack from here.
Menlo is another font designed by Jim Lyles (who also did the Vera family). It was first shipped with OS X Snow Leopard. It’s based on the Bitstream Vera Sans Mono typeface.
Dr. Drang wrote a very detailed comparison between Menlo and Bitstream Vera Sans Mono in 2009. The two fonts are almost identical.
Unless you have OS X “Snow Leopard” or a newer version of the OS X operating system, you can’t get Menlo. There is an Open Source copy called Meslo that you can try. Or just use Bitstream Vera Sans Mono, which as I said, is almost identical.
Monaco was the default monospaced typeface in OS X before the release of Snow Leopard in 2009, which introduced Menlo. It was designed by Susan Kare and Kris Holmes for Apple.
One of the distinctive features of Monaco is the round parenthesis that form a circle when typed in succession. The square brackets form a square. It also has a goofy feeling to it. I personally find it very distracting when coding.
I couldn’t find information about the license. Monaco still comes with OS X, so if you are on a Mac, you have it. Otherwise, there are some instruction on how to install it here.
Source Code Pro
You know which company has been involved in typography for a long time? Adobe. Back in 2012 they open sourced Source Sans Pro and later Source Code Pro. Both of these typefaces were designed by Paul D. Hunt.
Adobe’s editor Brackets uses this typeface by default.
I think it’s a pretty solid choice. It has a double‑story ‘g’ so it’s in my short list of favorites.
For the time being I’m sticking with Inconsolata. I like that it feels thinner than Consolas and I like the question mark better. My two second choices would be Hack—which gets dinged by having a single‑story ‘g’—and Source Code Pro.
I hope this article has helped you in choosing a good programming font. If you are going to stare at a computer screen all day, why not make it easy on the eyes?
If I missed any fonts please let me know and I’ll add them here.
In the meantime, may your source be beautiful and bug‑free.