Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I install fonts programatically on a Mac? And what steps are necessary?

I want to create a program that takes a font file and installs it on the Client's Mac.

share|improve this question
add comment

migrated from stackoverflow.com Mar 16 '10 at 19:24

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 5 down vote accepted

My previous answer was for the unedited question. To answer the new question of how to install fonts programatically on a Mac, Rich's answer is correct, just move them into the fonts folder.

EDIT: To fit within the spirit of my previous answer, here's a (roughly done) AppleScript which will install a font file located at /some/path/to/a/font_file.ttf by using the OS X application "Font Book"

set theFontPath to "/some/path/to/a/font_file.ttf"

set theFont to POSIX file theFontPath

tell application "Finder"
 open theFont
end tell

tell application "Font Book"
 activate
 set theFontWindow to the first window
end tell

tell application "System Events"
 tell process "Font Book"
  tell window 1
   tell group 1
    click button "Install Font"
   end tell
  end tell
 end tell
end tell

This could be executed in C++ via the osascript command; if you need help with that, it's a separate question altogether. Or you could do as Rich suggested and just move the file using the C rename() function.


Previous answer (for reference purposes only):

I suggest using the "Font Book" program located in /Applications. In addition to automatically coping the font to the proper font folders (outlined in Rich Bradshaw's answer) Font Book will verify the font before installing. Fonts are notorious for being corrupt and causing issues. In addition, Font Book shows the fonts which are installed and allows you to disable them.

To add fonts using Font Book, open the application and choose "Add Fonts" from the "File" menu. Before doing this I highly recommend to choose "Preferences" from the "Font Book" menu and ensure that "Validate fonts before installing" is enabled. Also, here you can decide if the fonts will be installed just for the current user, or for all users of the computer.

share|improve this answer
    
Hi Josh, the question is moved to the superuser by mistake. anyway your answer looks exacly like i found in most forums. –  Avram Mar 16 '10 at 22:06
add comment

Move the font to ~/Library/Fonts, or if you want it available system wide and have root permissions, /Library/Fonts.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.