Hack An Editor: Fonts For Programming

We’ve recently noticed two different fonts aimed at programmers, each with a different approach to editor customization. The first, Fira Code, transparently converts common programming digraphs into single characters. For example, <- becomes an arrow and != (or <>) becomes a proper not equal sign. The other font, Hack (can’t argue with the name), aims to make commonly confused characters distinct. For example, the zero glyph has a very distinct appearance from the letter O.

It is pretty easy to understand how Hack works, but Fira seems a mystery at first. Your C++ compiler expects <- not an arrow, right? Fonts support ligatures–sequences of two symbols that run together (like æ). Clever use of these ligatures means that the compiler still sees -> but the screen displays an arrow.

Once you install the font, you still need to tell your editor to use the font, but that’s a setting in just about every IDE (even if you have to edit a configuration file somewhere). We have mixed feelings about Fira Code. It has a high cool factor, but it also feels like you are hiding the actual code and that doesn’t seem like a good thing.

If you want to roll your own, there are plenty of ways to create fonts. Naturally, you can even do it with a Web application (see video below). Of course, if you do we want to hear about it.

Thanks [k5rud] for pointing out Hack.

41 thoughts on “Hack An Editor: Fonts For Programming

        1. What makes you think there’s no benefit? Without the ligatures, lots of characters are overloaded – they get used for multiple things. “-“, “=”, etc. since they’re used in digraphs. Joining them helps to make them more distinct to your eye, so once you get used to it, you’d expect that dumb mistakes (= instead of ==, etc.) would get easier to see. Not saying it will for everyone, but you could imagine it would.

    1. I’ve run into languages where the combined digraph was the convention, both in print publications and the IDE. Fira Code would certainly be an excellent option in those cases, particularly if the developer wanted to break away from the language’s standard IDE. But yeah, it would take getting used to for conventional languages.

    1. I would bet that more than 5% of devs using plain vim, which should work, so long as you’re using an appropriate terminal. Still, that font seems like a bad idea to me, it smells of obfuscation, and that is a terrible thing in a programming font.

      1. Us poor Latin alphabet people have had it easy on the text input end that the idea of wyswyg text input is the norm. I know that in many Asian text input systems this form of character replacement is the norm. This is could lead to less mistakes by providing visually unique glyphs for programming idioms

  1. the zero glyph has a very distinct appearance from the letter O.

    That used to be the case for pretty much every pre-GUI computer system, usually with a slash through or a dot in the middle of the zero. Texas Instruments took a different path on their 99-4 and 99-4/A computers. The O and o had square corners while the 0 had the corner pixels left out to make them ’rounded’. (The 99-4 didn’t have lowercase so it was just O and 0.)

    For me one of the most annoying font things is when the uppercase I and lowercase l are identical, like with what I’m typing right now. Some even use the same character for the numeral 1.

  2. A pretty nice addition to the C/C++ standard could be to allow UTF-8 source code so that proper UTF-8 symbols could be used instead of , !=, etc. (Although I’m betting that there are non-obvious drawbacks to this which will kill that idea pretty quickly.)

    1. The Ada language has had wide character support for many years. It does look weird to have things like ae ligatures in source code. John Barnes’ book “Programming Ada 2012” has some examples.

      I don’t like this feature really because I suspect it means that the font you use in your editor becomes important, especially if certain fonts represent some of the more obscure characters in different ways. Wingdings is not recommended for writing Ada code :)

  3. I’ve used Dejavu Sans Mono in jEdit for many years, and I just can’t get away from it. The I is different from the 1 and l (haha that was a lowercase L) , the 0 and the O are different, the zero having a dot in the center etc. There really is something to the need of a good font. Some fonts would leave you fatigued after a whole day of looking at it.

    The more I study it, the more I realize that Dejavu Sans Mono is nearly identical to Hack.

    I would have to admit that those automatic ligatures would extremely annoy me. I tend to be annoyed by things like auto capitalization and auto correct such as that found in word processors. It’s a cool concept, and I’m favorable to anything that makes code more readable so I should give it a try.

  4. I’ve enjoyed the Anonymous Pro font for programming in the past, and still do on my personal machine. My current employer has our machines locked down so hard I can’t add a font.

    1. Came here to say this. I’ve been using Source Code Pro since the day it came out (showed up on HackerNews pretty much the same day). It’s now part of my dotfiles repo that I distribute to all my machines. Definitely worth the install.

  5. After doing a quick comparison of monospace fonts already installed on my PC, Hack is pretty much indistinguishable from Source Code Pro and DejaVu Sans Mono. No idea what they were packaged with that brought them to my computer, but they are both free. Lucida Console by comparison lacks the dot in the zero to distinguish it from the letter O, and the lowercase L is slightly less intuitive. They’re all streets ahead of Courier New though.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.