]> Shamusworld >> Repos - ttedit/blobdiff - src/glyphpoints.cpp
Added preview window to file loading dialog. :-)
[ttedit] / src / glyphpoints.cpp
index 856b85964e5d1c5764f1d7020d6fa0cc9baa9e0c..025f0e1ef3fde7be1c709ee943ada7084d23e7d9 100644 (file)
@@ -907,24 +907,29 @@ bool GlyphPoints::LoadGlyphFromFile(FILE * file)
 
        FreeAllocatedMemory();
 
-       fscanf(file, "%s V%f", line, &version);
-       fscanf(file, "%s %u", line, &numPoints);
+       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", &x[i], &y[i], (char *)&line);
+               fscanf(file, "%d %d %s\n", &x[i], &y[i], (char *)&line);
                onCurve[i] = (line[0] == 'T' ? true : false);
        }
 
-       fscanf(file, "%s %u", line, &numPolys);
+       num = fscanf(file, "POLYS %u\n", &numPolys);
        polyEnd = new uint16_t[numPolys];
 
        for(int i=0; i<numPolys; i++)
        {
-               fscanf(file, "%u", &polyEnd[i]);
+               fscanf(file, "%u\n", &polyEnd[i]);
        }
 
        return true;