+
+
+void GlyphPoints::InvertPolyDrawSequence(const uint16_t poly)
+{
+ if (poly >= numPolys)
+ throw GP_OUT_OF_RANGE;
+
+ uint16_t pointNum1 = GetPolyStart(poly);
+ uint16_t pointNum2 = GetPolyEnd(poly);
+
+ // Algorithm: Step through points in the polygon, swapping 1st and last, then
+ // 2nd and (last - 1), 3rd and (last - 2), etc. We only do this for half the
+ // points, as doing it for all would undo the swapping we did in the 1st half.
+ for(uint16_t i=0; i<GetNumPoints(poly)/2; i++)
+ {
+ IPoint point1 = GetPoint(pointNum1 + i);
+ IPoint point2 = GetPoint(pointNum2 - i);
+ SetPoint(pointNum2 - i, point1);
+ SetPoint(pointNum1 + i, point2);
+ }
+}
+
+
+// really need to do checking on the results from fscanf...
+bool GlyphPoints::LoadGlyphFromFile(FILE * file)
+{
+ char line[512];
+ float version;
+
+ FreeAllocatedMemory();
+
+ int num = fscanf(file, "TTEGLYPH V%f\n", &version);
+
+ // Check to see if this is really a glyph file
+ if ((num != 1) || (version != 1.0))
+ return false;
+
+ num = fscanf(file, "POINTS %u\n", &numPoints);
+ x = new int[numPoints];
+ y = new int[numPoints];
+ onCurve = new bool[numPoints];
+
+ for(int i=0; i<numPoints; i++)
+ {
+ fscanf(file, "%d %d %s\n", &x[i], &y[i], (char *)&line);
+ onCurve[i] = (line[0] == 'T' ? true : false);
+ }
+
+ num = fscanf(file, "POLYS %u\n", &numPolys);
+ polyEnd = new uint16_t[numPolys];
+
+ for(int i=0; i<numPolys; i++)
+ {
+ fscanf(file, "%u\n", &polyEnd[i]);
+ }
+
+ return true;
+}
+
+
+bool GlyphPoints::SaveGlyphToFile(FILE * file)
+{
+// GlyphPoints glyph = editWnd->pts;
+ fprintf(file, "TTEGLYPH V1.0\n");
+ fprintf(file, "POINTS %u\n", numPoints);
+
+ for(int i=0; i<numPoints; i++)
+ {
+ fprintf(file, "%d %d %s\n", x[i], y[i], (onCurve[i] ? "T" : "F"));
+ }
+
+ fprintf(file, "POLYS %u\n", numPolys);
+
+ for(int i=0; i<numPolys; i++)
+ {
+ fprintf(file, "%u\n", polyEnd[i]);
+ }
+
+ return true;
+}
+