I've adjusted the simple TrueType glyph rendering program I wrote a few weeks ago to output PostScript, using the appropriate drawing commands to give a perfectly smooth outline of the glyph.
Here's the new program: eps-unicode-character.c
I'm hoping to extend this enough to do some very simple typesetting. Basically, I just want to be able to generate nice tables of Japanese kana glyphs to hang on my wall, and I haven't been able to find anything that handles Japanese characters well enough when generating PostScript.
One nice thing about this program is that it was fairly easy to add some
‘debugging’ code to show where the start and end points of each
line or curve are, and also the control points. I've added an option
-d to do that. Here's what you get if you look closely at a bit
of a Times New Roman capital A:

Tracing glyph outlines
My program uses the FreeType library again. This time, instead of
getting FreeType to render a bitmap, we retrieve the glyph outline
(see the draw_outline() function in my program).
The outline of a glyph is made up of straight lines and curves, which can be fairly simply turned into PostScript commands to create a path of the appropriate shape (which can then be filled in). The FreeType documentation has more details about how glyph outlines work.
The easiest way of extracting the outline information is to call
the FT_Outline_Decompose() function, passing it a structure
containing pointers to some callback functions. You need to supply
four callback functions:
move_to— start new path segment, directly translates to PostScriptmovetooperatorline_to— straight line from current point, directly translates to PostScriptlinetooperatorcubic_to— cubic Bézier curve from current point, using two control points, exactly the same as the PostScriptcurvetooperatorconic_to— simpler Bézier curve using only one control point
The first three are trivial when outputting PostScript, but the
last doesn't map directly to any PostScript command (that I know of).
The solution is to work out which two control points to use with the
curveto operator to give the same curve. I wouldn't have the
faintest idea how to do this, but I found some code in Yudit that
does it, and the results look right to me.
Here's how I think it should work. You have the current point (place where the last drawing operation left off) which I'll call (x1,y1), and the place you're drawing to, (x2,y2). The conic curve has a single control point (cx,cy). The two control points to use for a cubic Bézier curve are:
((x1 + 2cx) / 3, (y1 + 2cy) / 3)
((2cx + x2) / 3, (2cy + y2) / 3)
Like I said, I don't know the maths for this stuff, so don't take my word for it.