23 Comments

What Font Do You Program With?

What’s the best font to program with? In this post, we’ll take a look at the default fonts used for a variety of editors, explore other popular programming fonts, and discuss what you should look for when evaluating a programming font.

font-post-image

Developers love to customize their environments. They install cool themes and handy plugins. Often, however, this customization effort excludes fonts. In fact, I would guess that many developers don’t know what font they’re using in their editor right now. Font ignorance isn’t necessarily a bad thing–most default fonts are pretty good. However, if you’re going to be working inside an editor for eight to ten hours a day, why not go the extra mile to understand what font options exist?

Default Fonts

To start, let’s take a look at the default fonts used for some different editors and IDEs.

MacOS Windows 10 Ubuntu
Sublime Text Menlo Consolas Monospace
Atom Menlo Consolas DejaVu Sans Mono
IntelliJ Idea Menlo Monospace DejaVu Sans Mono
Eclipse Monaco Consolas Monospace
Visual Studio Consolas
Visual Studio Code Menlo Consolas Droid Sans Mono
XCode Menlo
Notepad++ Courier New
Spacemacs Source Code Pro Source Code Pro Source Code Pro

The above table took me longer to create than I’d like to admit. It can be surprisingly difficult to figure out the default font for a given editor.

I was able to find documentation for some editors online. For others, I installed them and took a look at what font they used out of the box. Some programs defer to the operating system or runtime for font selection, and may list a generic font, usually called something like Monospace. This seems to be more common on Linux. Editors that can run in a terminal like Vim or Emacs use the font configured for the terminal environment, so it’s difficult to include them in the mix.

Menlo and Consolas are the two big winners from above. If you’re using a Mac, you’re likely using Menlo. Similarly, if you’re on Windows, you’re likely using Consolas. Here is what these two fonts look like:

menlo-ss

consolas-ss

As you can see, they look pretty similar, though there are some nuanced distinctions–namely the tail on f, the serif on l, the width of 0, and the size of the *. Menlo is also a bit wider.

Default fonts on Linux are more of a crapshoot, as they vary by distribution. There was even quite a bit of variation within Ubuntu. Several editors defer to the default monospaced font defined by the operating system. At any rate, this is what DejaVu Sans Mono looks like:

dejavu-sans-mono-ss

Notice the circles in the middles of the zero character, instead of the slashes that Menlo and Consolas use.

For some additional comparison, this is what Courier New and Source Code Pro (also listed in the table above) look like:

courier-new-ss

source-code-pro-ss

Comparing and Evaluating Fonts

Now that we’ve looked at some common default fonts, you might be wondering how to evaluate and compare them. While font preference is largely subjective, there are also important quantitative characteristics that a good programming font should have.

Monospaced

A good programming font should be monospaced. This goes without saying. All editors and IDEs default to some monospaced font. What “monospaced” means is that each character takes up the same amount of horizontal space on the screen. This allows text to line up nicely in your source code. All of the fonts mentioned in this post are monospaced.

Good Character Distinction

There are sets of characters that can look similar, such as zero and the letter O, or the number one and the letter L. Good programming fonts will make it easy to distinguish between these similar characters. These sets of characters are good to compare when evaluating programming fonts:

Set 1: zero and O O, o, 0
Set 2: one, I, and L 1 I i L l
Set 3: five and S 5 S s
Set 4: two and Z 2 Z z
Set 5: parenthesis and brackets ( { [ ] } )

Let’s take a look at how the popular fonts listed above deal with these characters:

menlo-numbers

consolas-letters

courier-new-numbers

dejavu-sans-mono-numbers

source-code-pro-numbers

monaco-numbers

Of the above fonts, Courier New is by far the worst. It doesn’t have a slash or dot in the zero character, and its one and lower case L look nearly identical. Consolas also has a similar-looking one and lower case L. The other fonts do a pretty good job distinguishing between similar characters.

License and Availability

Not all fonts are available on all operating systems—nor are all fonts free. For example, Consolas is available on Windows, but if you want to use it on a Mac, you need to purchase it. Often, if you install other Microsoft software, such as Office, the Consolas font will come with it. Similarly, Menlo comes installed on MacOS and can be difficult to get on other operating systems such as Windows.

This may not be a big deal if you mostly work on one operating system. However, if you jump between MacOS, Windows, and Linux, it’s good to know which fonts can jump between these environments with you.

Other Fonts

There are many font options available in addition to the set of defaults listed above. Here are a few frequently discussed and highly reviewed non-default fonts:

hack-ss

ubuntu-mono-ss

inconsolata-ss

If you’re interested in discovering other fonts, there are several great resources that discuss and review fonts. For example, this site offers in-depth user font reviews and ratings.

If you are using a non-default font and really love it, I would be interested to know what it is.