Eliminating font cache problems

Let us assume you decided to test your font in an application like TextEdit or Word. So, you install it in the system by either opening it in Apple’s Font Book app, by using a third-party app for the same purpose, or by simply dragging the font file into ~/Library/Fonts/.

Well, you shouldn’t. Why not? Because installing a font with the same name as a previously installed one can seriously mess up your font caches. Caches are collections of previously calculated data. They can speed up your computer because it does not have to reprocess the original information every time. Likewise, font caches allow your Mac to speed up the use of installed fonts because all the stuff your Mac had to calculate to make your font appear on the screen, has already been done. But, of course, if the original font has changed, and the font cache does not know about it, then the data stored in it is outdated and most likely wrong.

Typical symptoms include:

  • The font menu does not show your font anymore
  • Glyphs do not appear at all
  • Changes you made in the font do not appear on the screen
  • Glyphs appear garbled and messed up on screen
  • You type one letter, but a different one appears
  • Paragraphs do not reflow properly
  • Your font does not print, or prints wrong or garbled letters

Or any other font weirdness, really.

Cleaning caches

If this happens to you, delete the font from Font Book or whatever third-party utility you use. Important: Don’t just deactivate it, REMOVE IT. Afterwards, open up your Terminal.app (you can find it in /Applications/Utilities/) and type the following commands. Each line must be finished by pressing the Return key. The first line will prompt you for your password:

sudo atsutil databases -remove
atsutil server -shutdown
atsutil server -ping

And now, restart your Mac. No, really, open the Apple menu in the top left corner and choose Restart. Don’t think you can get away without a restart, otherwise the trouble will reappear. And you really do not want that, do you?

Since you are on a Mac, you can put these commands in an AppleScript, and thus, do not need to remember the Terminal voodoo or go looking for this blogpost again. Open AppleScript Editor, located in your /Utilities/ folder, and copy and paste this into the AppleScript window:

try
    do shell script "sudo atsutil databases -remove" with administrator privileges
on error errMsg number errNum
    display dialog "Font cache error " & errNum & ": " & errMsg
end try
do shell script "atsutil server -shutdown"
do shell script "atsutil server -ping"
set buttonAnswer to text of button returned of (display dialog "It is strongly recommended that you restart your Mac, or at least log out and back in again." with title "Font caches cleaned" with icon caution buttons {"Restart", "Log out", "Later"} default button 3)
if buttonAnswer is "Log out" then
    tell application "System Events" to log out
else if buttonAnswer is "Restart" then
    tell application "System Events" to restart
end if

Save the script in ~/Library/Scripts/ and activate the Show Script menu in menu bar option in the AppleScript Editor preferences.

In the top right corner of your screen, your Mac displays a range of menu bar items. One of them is the Script menu. It allows you to run AppleScripts saved in the Scripts folder inside your Library:

Now you can remove the font from your system, run the script, restart your Mac, and you can install the new version of your font.

Avoiding cache problems

There are two simple ways to avoid the cache problems in the first place. Firstly, test your fonts in Adobe apps. They have a special Fonts folder, fonts saved into these folders are active in Adobe apps right away, and, most importantly, they are not cached.

Secondly, if you really have to test your font in the system, then change the Family Name every time you install the font. You can extend the name by a number or a letter. Since the font caches are linked to the font name, a new installation of the font with a different name will not conflict with a previous installation.

Update 2013-07-04: Clarified where to delete the font.

Update 2014-06-16: Removed the superfluous user-specific cache-cleaning, the sudo line removes all caches.

May 24, 2013 Modified on June 16, 2014