So you're given an archive containing 10,000,000 .ttf files, most of which are named things like "bs019dfk.ttf". How do you extract human readable names from these things?
If you're like me you think, "No problem! There has to be a command line utility for that!"
...then about an hour later you think, "I hope to god there's a command line utility for this".
...then you open a .ttf file in a text editor just in case the name will somehow magically be there.
...then you start drinking.
Well, good news for your liver. While I couldn't find a stock utility to extract the name from the .ttf file, I was able to find a little code to do so.
It's in python, and you'll need the FontTools library installed. And you should know that this code is blatently copied from the TTFQuery project.
#!/usr/bin/python import sys from fontTools import ttLib FONT_SPECIFIER_NAME_ID = 4 FONT_SPECIFIER_FAMILY_ID = 1 def shortName( font ): """Get the short name from the font's names table""" name = "" family = "" for record in font['name'].names: if record.nameID == FONT_SPECIFIER_NAME_ID and not name: if '\000' in record.string: name = unicode(record.string, 'utf-16-be').encode('utf-8') else: name = record.string elif record.nameID == FONT_SPECIFIER_FAMILY_ID and not family: if '\000' in record.string: family = unicode(record.string, 'utf-16-be').encode('utf-8') else: family = record.string if name and family: break return name, family tt = ttLib.TTFont(sys.argv[1]) print shortName(tt)[0]
To use it, just do this:
$ ttf_name somefont.ttf
Or to get all of the font names in a directory tree:
$ find . -iname "*.ttf" -exec ttf_name {} \;
Fruitopia
Pokemon Hollow Normal
Kitty Katt
BTSE + PS2 FONT
BatmanForeverOutline
Walt Disney Script v4.1
NewWGL4Font
Oreos
Halo OutlineRegular