On glyphs with duplicated points in the contour, the test for clockwise/anti-clockwise in FTContour::FTContour may fail, as the code tries to calculate the angle between degenerate points.
This can be repaired by using a signed area test for determining the winding, with the added benefit that all the expensive atan2 calls are avoided.
Code snippet below:
// Deterine the orientation of the contour by calculating the signed area of its control points.
// This is robust to repeated control points, and requires to trig functions.
double signedArea2 = 0.0; // This is really *twice* the signed area (though we're only checking sign)
for(unsigned int i = 0; i < n; i++) {
FTPoint pt0 = contour[i];
FTPoint pt1 = contour[(i+1)%n];
double a = (pt0.X()*pt1.Y() - pt0.Y()*pt1.X());
signedArea2 += a;
}
clockwise = (signedArea2 <= 0.0);
Sample font with repeated control points
headthinker.ttf (attached) has such contours on the '/', '3' and '7' glyphs.