C++ – How to interpret a free-glyph profile when the first point on the outline deviates from the curve

How to interpret a free-glyph profile when the first point on the outline deviates from the curve… here is a solution to the problem.

How to interpret a free-glyph profile when the first point on the outline deviates from the curve

I’m actually working on a renderer that converts freeform to polyline to control the laser marking system. The problem I’m having is that I don’t know how to properly handle contours that start with curved outer points (99.9% start with curved points!). I’ve searched for information for a long time but can’t find anything useful.

Thank you for your help

Solution

FreeType uses three types of points: quadratic control points (also known as “cones”) on curves and cubic control points. Quadratic control points are combined with points on the curve on either side of them to form the three points needed to define a quadratic Bezier spline. Cubic control points must appear in pairs and combined with curved points on both sides to form the four points required for a cubic Bezier spline.

However, only quadratic dots have abbreviations. Where quadratic points are next to each other, insert a control point on a curve between them. There is also a convention that if a closed path starts with a quadratic point, the last point of the path is checked, and if it is quadratic, a point on a curve is inserted between them, and then the path starts at a point on that curve; If the last point is not a secondary control point, it itself is used as a starting point.

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

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

The section of particular interest starts with this comment (note again that in this context, “cone” has the same meaning as “quadratic”):

/* first point is conic control.  Yes, this happens. */

Related Problems and Solutions