Install Fonts on Your Mac from the Command Line with Homebrew
There’s a really nice way to install fonts from the command line if you’re using macOS. Let’s dig into why you might want to install fonts this way, and then we’ll cover the details of how to do so.
Why Install Fonts from the Command Line?
One of the things that I always forget to do when I set up a new computer is to install all of the special fonts that we use at Corgibytes. We use these in the documents that we write for our customers, and we also use them in any presentations that we put together.
In the past, the process I’ve used for getting these installed has been to visit the different sites that host the fonts, download them, and then double click on the downloaded files to install the font. Each font usually has multiple files that have to be opened this way.
I find this process time consuming, and I have trouble figuring out which files I’ve opened so far. Another annoyance is having to find the site that hosts the fonts each time. This isn’t something that I have to do often, but every time I do, it costs me a lot of time and causes me a lot of frustration.
A much easier way to solve this problem is to run a few simple commands.
Setup
We’re going to use a package management tool called Homebrew to install our fonts, so before you continue, you need to make sure that you have Homebrew correctly installed.
The easiest way to do that is to execute the following command in a terminal window:
/usr/bin/ruby -e \
"$(curl -fsSL \
https://raw.githubusercontent.com/Homebrew/install/master/install)"
It’s typically not the best idea to just run random scripts by copying them and pasting them, especially if you don’t know what they are doing. You can read the script to get a sense of what it’s going to do first, or you can follow alternative installation instructions for Homebrew.
Homebrew is named after the practice of making your own beer at home. Many of the related commands are also beer related references, such as cask
and tap
.
Once you have Homebrew installed, you need to install a Homebrew extension called Homebrew Cask, which lets you install extra objects that are not included in the built-in list of objects that you can install with Homebrew. To do that, you need to run this command:
brew tap homebrew/cask
Now that you have Homebrew and Homebrew Casks installed, you can “tap” the font “cask” by running this command:
brew tap homebrew/cask-fonts
You can also create your own “tap” for storing fonts that are not listed in the office Homebrew Cask Fonts. We’ve done that to host one of the fonts that we use. You’ll need to “tap” it as well in order to install that font. To do that run this command:
brew tap corgibytes/cask-fonts
Let’s Install Some Fonts
With all that setup completed, you can install a font using the following command:
brew cask install font-[font-name]
For example, you can install the Corgibytes brand fonts (and some others) with:
brew cask install font-covered-by-your-grace
brew cask install font-hack
brew cask install font-league-gothic
brew cask install font-rambla
brew cask install font-share-tech
Running brew search "/font-/"
will show you a list of all fonts that you can install this way.
Can’t Find the Font You’re Looking For?
If your favorite font isn’t found when you search, you can add it by adding a new font cask and opening up a pull request. Here’s an example: https://github.com/Homebrew/homebrew-cask-fonts/pull/1470.
You can also create your own repository for storing fonts like we did, if you think the font that you want to use won’t be accepted by the Homebrew team.
How do I do something similar on Windows or Linux?
That’s a great question to which I don’t know the answer! If you do, please leave a comment or drop me a note on Twitter.
Want to be alerted when we publish future blogs? Sign up for our newsletter!