6 // This class encapsulates the data associated with a TrueType glyph.
7 // Data is dynamically allocated.
10 #ifndef __GLYPHPOINTS_H__
11 #define __GLYPHPOINTS_H__
17 // "IPoint" is an Integer based Point
23 IPoint(int32_t xx=0, int32_t yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}
24 bool operator==(const IPoint & p) { return (p.x == x && p.y == y ? true: false); };
35 // Throws the following exceptions:
36 #define GP_OUT_OF_RANGE 1
41 //For some reason, gcc barfs here when something tries to use the copy
42 //constructor because it gets confused between the optional arguments (which
43 //start with an INT for cryin' out loud) and the GlyphPoints & argument. So,
44 //Let's try making it a non-optional first param, and go from there...
45 //Turns out the compiler barfs regardless...
46 //Turns out the problem was that the copy ctor wasn't declared as CONST...
47 GlyphPoints(int nPts = 0, int nPlys = 0, int * xa = NULL, int * ya = NULL,
48 bool * oca = NULL, uint16_t * pa = NULL);
49 // GlyphPoints(void);// And now *this* is needed... Bleah!
50 // GlyphPoints(int nPts, int nPlys = 0, int * xa = NULL, int * ya = NULL,
51 // bool * oca = NULL, uint16_t * pa = NULL);
52 GlyphPoints(int xx, int yy, bool oc);
53 // GlyphPoints(GlyphPoints &); // Copy constructor
54 GlyphPoints(const GlyphPoints &); // Copy constructor
56 GlyphPoints& operator=(const GlyphPoints &);
57 GlyphPoints operator+(const GlyphPoints &);
58 GlyphPoints operator+(const IPoint &);
59 GlyphPoints& operator+=(const IPoint &);
61 void InsertPoint(uint16_t, int, int, bool);
62 void InsertPoint(uint16_t, const IPoint &);
63 void DeletePoint(uint16_t);
64 uint16_t GetNumPoints(void);
65 uint16_t GetNumPoints(uint16_t poly);
66 uint16_t GetNumPolys(void);
69 bool GetOnCurve(uint16_t);
70 int GetX(uint16_t, uint16_t);
71 int GetNextX(uint16_t, uint16_t);
72 int GetY(uint16_t, uint16_t);
73 int GetNextY(uint16_t, uint16_t);
74 IPoint GetPoint(uint16_t, uint16_t);
75 IPoint GetPoint(uint16_t);
76 bool GetOnCurve(uint16_t, uint16_t);
77 bool GetPrevOnCurve(uint16_t, uint16_t);
78 bool GetNextOnCurve(uint16_t, uint16_t);
79 uint16_t GetPolyStart(uint16_t);
80 uint16_t GetPolyEnd(uint16_t);
81 void OffsetPoints(int, int);
82 void OffsetPoly(uint16_t, int32_t, int32_t);
83 void ScalePoints(float);
84 void SetXY(uint16_t, int, int);
85 void SetOnCurve(uint16_t, bool);
86 void SetPoint(const uint16_t pointNum, const IPoint point);
87 uint16_t GetPrev(uint16_t);
88 uint16_t GetNext(uint16_t);
89 uint16_t GetPrev(uint16_t, uint16_t);
90 uint16_t GetNext(uint16_t, uint16_t);
91 uint16_t GetPoly(uint16_t);
92 void AddNewPolyAtEnd(void);
93 IPoint GetMidpointToPrev(uint16_t, uint16_t);
94 IPoint GetMidpointToNext(uint16_t, uint16_t);
95 IPoint GetPrevPoint(uint16_t, uint16_t);
96 IPoint GetNextPoint(uint16_t, uint16_t);
97 uint16_t GetPolyForPoint(IPoint point);
98 uint16_t GetPolyForPointNumber(uint16_t pointNumber);
100 IPoint RotatePoint(const double angle, const IPoint point, const IPoint center);
101 void RotatePoints(const double angle, const IPoint point);
102 IPoint GetPolyCentroid(const int16_t poly);
103 void RotatePolyAroundCentroid(const int16_t poly, const double angle);
104 void InvertPolyDrawSequence(const uint16_t poly);
106 bool LoadGlyphFromFile(FILE *);
107 bool SaveGlyphToFile(FILE *);
110 void AllocateAndCopy(int, int, int *, int *, bool *, uint16_t *);
111 void FreeAllocatedMemory(void);
114 int numPoints, numPolys;
118 uint16_t pointsAllocated, polysAllocated;
121 #endif // __GLYPHPOINTS_H__