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