3

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

chrmue
  • 1,552
  • 2
  • 18
  • 35
  • update: to solve the issue I tried to close the outline in the manner that I use the LAST point of the contour (which is on curve) as the first point of the bezier. The character renders correctly now. What I don't like about the solution is that it seems to be a kind of a hack and I'm not shure if it the right way to do it. – chrmue Aug 12 '10 at 08:50
  • It is absolutely the right way to do it. Be on the lookout for contours with _no_ explicit on-curve points (actually common for circlular shapes like O). – David Jones Apr 11 '22 at 12:30

1 Answers1

4

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. */
Graham Asher
  • 1,648
  • 1
  • 24
  • 34