7

On OS X you can install .ttf font files by double clicking them. This is a hassle when dealing with multiple files. Is there a command to install font files using the Terminal app ?

Something Else
  • 91
  • 1
  • 1
  • 3
  • 3
    This question is more general computing than programming-related and is [off-topic](http://stackoverflow.com/help/on-topic) for Stack Overflow. It would be more appropriate for [Super User](http://superuser.com/) or [Ask Different](http://apple.stackexchange.com/). – Anthony Geoghegan Nov 23 '15 at 10:37
  • 1
    Very sorry for this misunderstanding. In the future I will post on the correct forum. – Something Else Nov 23 '15 at 11:01
  • 1
    No worries. It's quite a common misunderstanding. FWIW, `open *.ttf` may do what you want. – Anthony Geoghegan Nov 23 '15 at 11:15

3 Answers3

18

You could copy the fonts using

cp myfont.ttf /Library/Fonts/

or multiple files

cp fontsFolder/*.ttf /Library/Fonts/
Nirmi
  • 1,099
  • 1
  • 8
  • 20
  • 2
    Thanks ! But it seems like OS X does more than just copying them to that folder when you double click the font and then click "Install" ? – Something Else Nov 23 '15 at 10:57
  • 1
    As far as i know some fonts needs to get confirmed manually if you want to install them. And open manually you are able to sort them into different groups. For me copying help most of the time – Nirmi Nov 23 '15 at 15:43
  • Copying into the `Fonts` folder worked fine for using fonts programmatically with python. I added an answer below for installing fonts from a github repo in one line. – jlansey Apr 09 '18 at 11:16
  • I’m guessing python sets auto-activation for itself or manually activates fonts it wants to use. – Joshua Nozzi Dec 11 '20 at 18:44
1

Install fonts with the following command line. Replace BRLNSR with your font and add in more lines if you need more fonts.

cd ~/Library/Fonts && { curl -O 'https://github.com/bloomberg/scatteract/raw/master/fonts/BRLNSR.TTF' ; cd -; }

This code does the following:

  1. cd into the fonts directory
  2. curl downloads the font
  3. pops back to the original directory

This relies on the very nice bloomberg fonts github repo with a bunch of fonts stored - but you could change the curl url to wherever the font you want is located online.

The clever way the cd into a directory, download and pop out again came from user Atle's answer here.

jlansey
  • 3,996
  • 2
  • 17
  • 15
0

To make the newly copied fonts available to applications requires activating them (for the process, for the user, or for the whole system). This you can do programmatically through various CoreText commands, depending on what you want to do with the font(s). I’m not sure if there’s a way to do this from the command line without turning on auto-activation for everything. See atsutil man pages for (scant) details.

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135