2013-09-05

Creating font metrics for Apache FOP

Whilst searching for a proper solution to create font metrics for a bunch of TrueType fonts to be used with Apache FOP I came up with the following BASH Shell-Script snippet:

for ttf_file in *.ttf; do
    fop-ttfreader "${ttf_file}" \
                  "${ttf_file%%.ttf}-metrics.xml";
done

It will create metric files for all TrueType fonts (*.ttf) located in the current directory.

Just make sure to install Apache FOP first. On my Ubuntu GNU/Linux box I had to install a package called "fop":

# sudo apt-get install fop