Skip to content
Advertisement

how to interpret a freetype glyph outline when the first point on the contour is off curve

I’m actually working on a renderer that converts freetype glyphs into polylines to control a laser marking system. The problem I have is that I don’t know how to handle correctly a contour beginning with an off curve point (99.9% begin with on curve points!). I’ve searched quite a while now for informations but I couldn’t find anything useful.

Thanks for your help

Advertisement

Answer

FreeType uses three types of points: on-curve, quadratic control points (also known as ‘conic’) and cubic control points. The quadratic control points are grouped with on-curve points on either side of them to form the three points needed to define a quadratic Bézier spline. The cubic control points must occur in pairs, and are grouped with on-curve points on either side to make up the four points needed for a cubic Bézier spline.

However, there is a short-hand notation for quadratic points only. Where quadratic points occur next to each other, an on-curve control point is interpolated between them. And there is another convention, that if a closed path starts with a quadratic point, the last point of the path is examined, and if it is quadratic, an on-curve point is interpolated between them, and the path is taken to start with that on-curve point; if the last point is not a quadratic control point, it is itself used for the start point.

If you want to see exactly how this is done, please look at the FreeType source code. The function FT_Outline_Decompose traverses a path and converts it into a series of lines and curves of both types. It’s in this file:

http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/src/base/ftoutln.c

The part of especial interest starts with this comment (note again that ‘conic’ means the same as ‘quadratic’ in this context):

/* first point is conic control.  Yes, this happens. */
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement