Find corrupt fonts using Spotlight in Terminal

Jul 25, '08 07:30:05AM

Contributed by: spfolly

In doing an mdimport -A in Terminal, I noticed a particular attribute called com_apple_ats_font_invalid. Spotlight seems to set this attribute for files in a font folder (e.g. ~/Library/Fonts) that aren't valid font files. Try this is a Terminal window to see if you have any bad fonts:

$ mdfind "com_apple_ats_font_invalid == 1"
You can see this in action if you use the -live switch on the above command. Once the mdfind starts, in another Terminal window, create a bad font:
$ echo "bad font" > ~/Library/Fonts/badfont.ttf
You'll see that the query in the first window now shows one match; remove the file you just created (rm ~/Library/Fonts/badfont.ttf), and the query count will drop to zero. Press Control-C to end the mdfind in the other window.

I'm not sure if this is new for Leopard or whether Tiger has it as well.

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080721155438538