+void EditWindow::DrawGlyphPoly(QPainter & p, GlyphPoints & glyph, uint16 poly)
+{
+ // Sanity check
+ if (glyph.GetNumPoints(poly) < 3)
+ return;
+
+ // Initial move: If our start point is on curve, then go to it. Otherwise,
+ // check previous point. If it's on curve, go to it otherwise go the
+ // midpoint between start point and previous (since it's between two curve
+ // control points).
+ IPoint pt = (glyph.GetOnCurve(poly, 0)
+ ? glyph.GetPoint(poly, 0) : (glyph.GetPrevOnCurve(poly, 0)
+ ? glyph.GetPrevPoint(poly, 0) : glyph.GetMidpointToPrev(poly, 0)));
+
+ for(int i=0; i<glyph.GetNumPoints(poly); i++)
+ {
+ // If this point and then next are both on curve, we have a line...
+ if (glyph.GetOnCurve(poly, i) && glyph.GetNextOnCurve(poly, i))
+ {
+ IPoint pt2 = glyph.GetNextPoint(poly, i);
+ p.drawLine(pt.x, pt.y, pt2.x, pt2.y);
+ pt = pt2;
+ }
+ else
+ {
+ // Skip point if it's on curve (start of curve--it's already
+ // been plotted so we don't need to handle it...)
+ if (glyph.GetOnCurve(poly, i))
+ continue;
+
+ // We are now guaranteed that we are sitting on a curve control point
+ // (off curve). Figure the extent of the curve: If the following is a
+ // curve control point, then use the midpoint to it otherwise go to
+ // the next point since it's on curve.
+ IPoint pt2 = (glyph.GetNextOnCurve(poly, i)
+ ? glyph.GetNextPoint(poly, i) : glyph.GetMidpointToNext(poly, i));
+
+ Bezier(p, pt, glyph.GetPoint(poly, i), pt2);
+ pt = pt2;