Wednesday, February 20, 2008
Font tips #1: PDF charts with fntsample
Around the end of 2006 I come up with the idea of setting up something I called font-machine: a collection of scripts / utilities, intended to improve quality of fonts by defining and implementing automatic tests able to catch errors and provide screenshots.
Some pioneering work on this area was done a while ago by Miriam who set up a page showing how fonts currently in Debian look like.
I did something similar focusing on the fonts used by the Debian graphical installer (will write a separate post to describe the way it works).
I'll start describing the tools which I've used more frequently; of course my preference goes to the ones which can be run non-interactively: those that can be invoked inside shell scrips and keep your CPU busy!
fntsample is probably one of the programs I've used more frequently during the last months: it was written by Eugeniy Meshcheryakov, who also made it available as a Debian package, and creates really nice and professional PDF / PS charts showing all the glyphs contained in a particular font file.
The following code snippet shows how you can use fntsample to create pdf charts for each of the ttf files contained in ttf-dejavu package (will often refer to this package since I maintain it :-) ):
font="http://ftp.de.debian.org/debian/pool/main/t/ttf-dejavu/ttf-dejavu-core_2.23-1_all.deb"
deb=$(basename ${font})
wget $font
dpkg -x ${deb} ${deb/.deb/}
outdir="out"
mkdir $outdir
for ttf in $(find ${deb/.deb/} -name '*.ttf') ; do
pdf="$(basename ${ttf} | sed -e "s|\.ttf$|\.pdf|")"
fntsample -f ${ttf} -o ${outdir}/${pdf} -l > ${outdir}/${pdf/.pdf/.outline}
pdfoutline ${outdir}/${pdf} ${outdir}/${pdf/.pdf/.outline} ${outdir}/${pdf}
done
Note that PDF files will have useful outlines (aka bookmarks) courtesy of the pdfoutline tool shipped with the fntsample package.
Results are IMHO very imperessive!
PS: looking at the above chart for Cyrillic, I've just noticed the glyphs are ordered as to read "SEX"... I did not choose that particular chart snippet on purpose!