// JLH = James L. Hammons <jlhamm@acm.org>
//
// Who When What
-// --- ---------- ------------------------------------------------------------
+// --- ---------- -----------------------------------------------------------
// JLH ??/??/200? Created this file
// JLH 05/18/2004 Added pure point adding, inserting, better polygon handling
//
GlyphPoints::~GlyphPoints()
{
FreeAllocatedMemory();
-#if 0
- if (x)
- delete[] x;
-
- if (y)
- delete[] y;
-
- if (onCurve)
- delete[] onCurve;
-
- if (polyEnd)
- delete[] polyEnd;
-#endif
}
void GlyphPoints::InsertPoint(uint16_t pt, int xx, int yy, bool oc)
{
+//wouldn't it be better to treat this case as inserting at the end?
if (pt > numPoints) // > because we can insert at end...!
throw GP_OUT_OF_RANGE;
//we're adding to the end of the structure: [DONE, below]
int polyInsert = (pt == numPoints ? numPolys - 1 : GetPoly(pt));
for(int i=polyInsert; i<numPolys; i++)
-// for(int i=GetPoly(pt); i<numPolys; i++)
polyEnd[i]++; // Bump polygons' end point
numPoints++;
}
+Vector GlyphPoints::GetXY(uint16_t pt)
+{
+ if (pt >= numPoints)
+#ifdef DEBUG
+{
+WriteLogMsg("Exception: GetXY(uint16_t). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
+#endif
+ throw GP_OUT_OF_RANGE;
+#ifdef DEBUG
+}
+#endif
+
+ return Vector(x[pt], y[pt]);
+}
+
+
bool GlyphPoints::GetOnCurve(uint16_t pt)
{
if (pt >= numPoints)
{
uint16_t prevPt = GetPrev(poly, pt);
- return IPoint(GetX(poly, prevPt), GetY(poly, prevPt));
+ return IPoint(GetX(poly, prevPt), GetY(poly, prevPt), GetOnCurve(poly, prevPt));
}
{
uint16_t nextPt = GetNext(poly, pt);
- return IPoint(GetX(poly, nextPt), GetY(poly, nextPt));
+ return IPoint(GetX(poly, nextPt), GetY(poly, nextPt), GetOnCurve(poly, nextPt));
}
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;