The TrueType to Type42 conversion is tricky. The FreeType support is almost useless here and we have to implement everything manually. It is a work of black magic and intensive hacking.
First, the Type42 header is constructed according to information provided by FreeType. We then load the important TrueType font tables by manually parsing the TrueType file. Then we construct a modified TrueType file copy, changed for the purpose of Type42 enveloping. This includes building a new TrueType directory and encoding everything in ASCII.