-//\r
-// glyphpoints.h\r
-//\r
-// by James L. Hammons\r
-//\r
-// This class encapsulates the data associated with a TrueType glyph.\r
-// Data is dynamically allocated.\r
-//\r
-\r
-#ifndef __GLYPHPOINTS_H__\r
-#define __GLYPHPOINTS_H__\r
-\r
-#include "types.h"\r
-\r
-\r
-struct IPoint\r
-{\r
- int32 x, y;\r
- bool onCurve;\r
-\r
- IPoint(int32 xx=0, int32 yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}\r
-};\r
-\r
-// Throws the following exceptions:\r
-#define GP_OUT_OF_RANGE 1\r
-\r
-class GlyphPoints\r
-{\r
- public:\r
-//For some reason, gcc barfs here when something tries to use the copy\r
-//constructor because it gets confused between the optional arguments (which\r
-//start with an INT for cryin' out loud) and the GlyphPoints & argument. So,\r
-//Let's try making it a non-optional first param, and go from there...\r
-//Turns out the compiler barfs regardless...\r
-//Turns out the problem was that the copy ctor wasn't declared as CONST...\r
- GlyphPoints(int nPts = 0, int nPlys = 0, int * xa = NULL, int * ya = NULL,\r
- bool * oca = NULL, uint16 * pa = NULL);\r
-// GlyphPoints(void);// And now *this* is needed... Bleah!\r
-// GlyphPoints(int nPts, int nPlys = 0, int * xa = NULL, int * ya = NULL,\r
-// bool * oca = NULL, uint16 * pa = NULL);\r
- GlyphPoints(int xx, int yy, bool oc);\r
-// GlyphPoints(GlyphPoints &); // Copy constructor\r
- GlyphPoints(const GlyphPoints &); // Copy constructor\r
- ~GlyphPoints();\r
- GlyphPoints& operator=(const GlyphPoints &);\r
- GlyphPoints operator+(const GlyphPoints &);\r
- GlyphPoints operator+(const IPoint &);\r
- GlyphPoints& operator+=(const IPoint &);\r
- void InsertPoint(uint16, int, int, bool);\r
- void InsertPoint(uint16, const IPoint &);\r
- void DeletePoint(uint16);\r
- uint16 GetNumPoints(void);\r
- uint16 GetNumPoints(uint16);\r
- uint16 GetNumPolys(void);\r
- int GetX(uint16);\r
- int GetY(uint16);\r
- bool GetOnCurve(uint16);\r
- int GetX(uint16, uint16);\r
- int GetY(uint16, uint16);\r
- bool GetOnCurve(uint16, uint16);\r
- uint16 GetPolyEnd(uint16);\r
- void OffsetPoints(int, int);\r
- void OffsetPoly(uint16, int32, int32);\r
- void ScalePoints(float);\r
- void SetXY(uint16, int, int);\r
- void SetOnCurve(uint16, bool);\r
- uint16 GetPrev(uint16);\r
- uint16 GetNext(uint16);\r
- uint16 GetPrev(uint16, uint16);\r
- uint16 GetNext(uint16, uint16);\r
- uint16 GetPoly(uint16);\r
- void AddNewPolyAtEnd(void);\r
-\r
- private:\r
- void AllocateAndCopy(int, int, int *, int *, bool *, uint16 *);\r
-\r
- private:\r
- int numPoints, numPolys;\r
- int * x, * y;\r
- bool * onCurve;\r
- uint16 * polyEnd;\r
- uint16 pointsAllocated, polysAllocated;\r
-};\r
-\r
-#endif // __GLYPHPOINTS_H__\r
+//
+// glyphpoints.h
+//
+// by James L. Hammons
+//
+// This class encapsulates the data associated with a TrueType glyph.
+// Data is dynamically allocated.
+//
+
+#ifndef __GLYPHPOINTS_H__
+#define __GLYPHPOINTS_H__
+
+#include <stdint.h>
+#include <stdio.h>
+#include "vector.h"
+
+
+// "IPoint" is an Integer based Point
+struct IPoint
+{
+ int32_t x, y;
+ bool onCurve;
+
+ IPoint(int32_t xx=0, int32_t yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}
+ bool operator==(const IPoint & p) { return (p.x == x && p.y == y ? true: false); };
+};
+
+
+struct GuideLine
+{
+ int32_t x, y;
+ double angle;
+};
+
+
+// Throws the following exceptions:
+#define GP_OUT_OF_RANGE 1
+
+class GlyphPoints
+{
+ public:
+//For some reason, gcc barfs here when something tries to use the copy
+//constructor because it gets confused between the optional arguments (which
+//start with an INT for cryin' out loud) and the GlyphPoints & argument. So,
+//Let's try making it a non-optional first param, and go from there...
+//Turns out the compiler barfs regardless...
+//Turns out the problem was that the copy ctor wasn't declared as CONST...
+ GlyphPoints(int nPts = 0, int nPlys = 0, int * xa = NULL, int * ya = NULL,
+ bool * oca = NULL, uint16_t * pa = NULL);
+// GlyphPoints(void);// And now *this* is needed... Bleah!
+// GlyphPoints(int nPts, int nPlys = 0, int * xa = NULL, int * ya = NULL,
+// bool * oca = NULL, uint16_t * pa = NULL);
+ GlyphPoints(int xx, int yy, bool oc);
+// GlyphPoints(GlyphPoints &); // Copy constructor
+ GlyphPoints(const GlyphPoints &); // Copy constructor
+ ~GlyphPoints();
+ GlyphPoints& operator=(const GlyphPoints &);
+ GlyphPoints operator+(const GlyphPoints &);
+ GlyphPoints operator+(const IPoint &);
+ GlyphPoints& operator+=(const IPoint &);
+ void Clear(void);
+ void InsertPoint(uint16_t, int, int, bool);
+ void InsertPoint(uint16_t, const IPoint &);
+ void DeletePoint(uint16_t);
+ uint16_t GetNumPoints(void);
+ uint16_t GetNumPoints(uint16_t poly);
+ uint16_t GetNumPolys(void);
+ int GetX(uint16_t);
+ int GetY(uint16_t);
+ Vector GetXY(uint16_t);
+ bool GetOnCurve(uint16_t);
+ int GetX(uint16_t, uint16_t);
+ int GetNextX(uint16_t, uint16_t);
+ int GetY(uint16_t, uint16_t);
+ int GetNextY(uint16_t, uint16_t);
+ IPoint GetPoint(uint16_t, uint16_t);
+ IPoint GetPoint(uint16_t);
+ bool GetOnCurve(uint16_t, uint16_t);
+ bool GetPrevOnCurve(uint16_t, uint16_t);
+ bool GetNextOnCurve(uint16_t, uint16_t);
+ uint16_t GetPolyStart(uint16_t);
+ uint16_t GetPolyEnd(uint16_t);
+ void OffsetPoints(int, int);
+ void OffsetPoly(uint16_t, int32_t, int32_t);
+ void ScalePoints(float);
+ void SetXY(uint16_t, int, int);
+ void SetOnCurve(uint16_t, bool);
+ void SetPoint(const uint16_t pointNum, const IPoint point);
+ uint16_t GetPrev(uint16_t);
+ uint16_t GetNext(uint16_t);
+ uint16_t GetPrev(uint16_t, uint16_t);
+ uint16_t GetNext(uint16_t, uint16_t);
+ uint16_t GetPoly(uint16_t);
+ void AddNewPolyAtEnd(void);
+ IPoint GetMidpointToPrev(uint16_t, uint16_t);
+ IPoint GetMidpointToNext(uint16_t, uint16_t);
+ IPoint GetPrevPoint(uint16_t, uint16_t);
+ IPoint GetNextPoint(uint16_t, uint16_t);
+ uint16_t GetPolyForPoint(IPoint point);
+ uint16_t GetPolyForPointNumber(uint16_t pointNumber);
+
+ IPoint RotatePoint(const double angle, const IPoint point, const IPoint center);
+ void RotatePoints(const double angle, const IPoint point);
+ IPoint GetPolyCentroid(const int16_t poly);
+ void RotatePolyAroundCentroid(const int16_t poly, const double angle);
+ void InvertPolyDrawSequence(const uint16_t poly);
+
+ bool LoadGlyphFromFile(FILE *);
+ bool SaveGlyphToFile(FILE *);
+
+ private:
+ void AllocateAndCopy(int, int, int *, int *, bool *, uint16_t *);
+ void FreeAllocatedMemory(void);
+
+ private:
+ int numPoints, numPolys;
+ int * x, * y;
+ bool * onCurve;
+ uint16_t * polyEnd;
+ uint16_t pointsAllocated, polysAllocated;
+};
+
+#endif // __GLYPHPOINTS_H__