The Hack 2.0 font got a lot of attention recently as a font specifically designed for use with source code. So of course I had to try it out in Emacs. I started with installing it on Mac OS X as that’s the OS I use most for work and work – like activities.

To install the font on my Mac, I downloaded the TTF version of the font from the link above. Installing a new font in OS X is easy – unzip the downloaded file, then double-click on each ttf file that you just unzipped. This brings up the Font Book application. Just click “Install Font” and you’re done.

With the font installed, I needed to find out what Emacs believes the name of the font to be. The easiest way I found was to run M-x ns-popup-font-panel to bring up the OS X font picker, select the freshly installed Hack 2.0 font and then run M-x describe-font to pick out the correct name.

I plan to use the font for a little while to see how I like it so I wanted to tweak the default font setting to use the Hack 2.0 font as the default font. In my case, I only wanted to tweak the OS X settings part of my global .emacs, at least until I have the font installed on Linux and Windows also. Inserting the lines below into my .emacs achieves exactly that and sets the default font on OS X systems to Hack:

(when (eq system-type 'darwin)
      (set-default-font "-*-Hack-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1"))

Obviously the above is only a temporary change and once I decided if I am happy with the new font, I really need to set the default font family instead of the default font. However, the above suffices for a quick test.

The difference between Hack and the Menlo font that my OS X Emacs installation picks by default is very subtle. You can see that the height is different and in general, I find the Hack font a tad more readable. You can see a side-by-side comparison in the picture below.

Hack 2.0 and Menlo side by side
Font comparison – Hack 2.0 and Menlo side by side

Leave a Reply