Fixing font file names

The Characteristics of a Typeface (for widescr...

Image by arnoKath via Flickr

So you want to rationalise your font directory? Let’s face it, who doesn’t?

I had a bunch of old CDs lying around with fonts scattered throughout them. Going through each in turn I copied all the font files into a single working directory:

find -iname "*.ttf" -exec cp "{}" ~/fontwork

I also threw my installed fonts into the mix:

cp ~/.fonts/* ~/fontwork

fontwork ended up containing 1300+ files. Many of these had awful names like “basd12.ttf”. Just awful.

I decided to fix them up by extracting the embedded family and style information. Neither apt-cache nor google could find me an existing utility to pull out this info, so I quickly wrote one using the excellent freetype2 library. It’s imaginatively called fontinfo. I also wrote a little shell script to rename the font files and remove duplicates.

You can snag both from my github repository.