MMD Technical Study
Nic Mulvaney - Huddersfield University 2004
Obtaining Outlines
February 22, 2004 (582 Words)

I would like to get under the skin of type design and possibly analyse the structure of a font through its outlines. I often use Fontlab 4.5 and Macromedia Fontographer to edit and create typefaces, so the outline structure of a font is very familiar to me. I was wondering if the way an outline is stored could be used in a more useful and productive way.

Continuing my interest in font outlines I realised that fonts are stored as simple coordinates with two bezier° points*. There is no easy way to extract these points; opening a TrueType° font in a text editor will get you nowhere. For me to play with these points I need them in a format that can easily be integrated into other applications. A raw text file would be good, but an XML° file would perfect, that way I can work with the points in a wide variety of applications.

* Postscript fonts only have two beziers. TrueType fonts can include multiple quadratic handles.

After a search on the web, I came across TTX/FontTools which is a simple Command Line utility for converting TrueType fonts into TTX files (basically XML under a new name by the programmer). Being a Command Line utility, this means that it is possible to use it on an NT web-server and also I can use it in conjunction with Director or Flash (Using Flash Studio Pro).

The file that it creates for a font like Georgia° is over ten times as large in file size than the original font file. Georgia weighs in at 1.55MB. With my experience of XML in Macromedia Flash, I realised that this is a bit too large, and would be difficult for me to load in and out of environments if I require real-time authoring. I could write my own specifications for a font file, but after looking at the XML file, I saw that I could just strip a lot of data I would not be using from the file. This includes things like Hinting, Kerning, Metrics and Special Characters. The typical required data for a single letter A looks like this.

Now for a geeky part..

As I would be testing a lot of fonts and playing with TTX/FontTools a lot, I would need a way of stripping the XML files, which could be very time consuming (but not impossible) to do manually. I run a small web server° on my machine, which has PHP° installed. PHP is another of my interests, and is a fairly agile language for processing just about anything. I quickly wrote a script that could load a TTX file and extract only the data I wanted, and save it as a new Nic's Spec XML file.

[ View PHP code ]

This would cut a font like Georgia from 1.5MB to 129KB, much easier for me to handle.
A formatted XML file for uppercase and lowercase now looks like this (129KB, For reference only). I also had to rename tags from "on" to "m" because Actionscript uses "on" as a predefined event caller.

UPDATE - I have since found that I can keep the tags "on", and renaming is unneccesary, due to referencing it as a string instead of a variable.

So now I have extracted the font outlines from a font, I can now try and plot them in Flash and possibly Proce55ing.


Next Page... "Plotting Outlines in Proce55ing" »