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 xx=0, int32 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 * 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 * 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, int, int, bool);
62 void InsertPoint(uint16, const IPoint &);
63 void DeletePoint(uint16);
64 uint16 GetNumPoints(void);
65 uint16 GetNumPoints(uint16 poly);
66 uint16 GetNumPolys(void);
69 bool GetOnCurve(uint16);
70 int GetX(uint16, uint16);
71 int GetNextX(uint16, uint16);
72 int GetY(uint16, uint16);
73 int GetNextY(uint16, uint16);
74 IPoint GetPoint(uint16, uint16);
75 IPoint GetPoint(uint16);
76 bool GetOnCurve(uint16, uint16);
77 bool GetPrevOnCurve(uint16, uint16);
78 bool GetNextOnCurve(uint16, uint16);
79 uint16 GetPolyStart(uint16);
80 uint16 GetPolyEnd(uint16);
81 void OffsetPoints(int, int);
82 void OffsetPoly(uint16, int32, int32);
83 void ScalePoints(float);
84 void SetXY(uint16, int, int);
85 void SetOnCurve(uint16, bool);
86 void SetPoint(const uint16 pointNum, const IPoint point);
87 uint16 GetPrev(uint16);
88 uint16 GetNext(uint16);
89 uint16 GetPrev(uint16, uint16);
90 uint16 GetNext(uint16, uint16);
91 uint16 GetPoly(uint16);
92 void AddNewPolyAtEnd(void);
93 IPoint GetMidpointToPrev(uint16, uint16);
94 IPoint GetMidpointToNext(uint16, uint16);
95 IPoint GetPrevPoint(uint16, uint16);
96 IPoint GetNextPoint(uint16, uint16);
97 uint16 GetPolyForPoint(IPoint point);
98 uint16 GetPolyForPointNumber(uint16 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 poly);
103 void RotatePolyAroundCentroid(const int16 poly, const double angle);
104 void InvertPolyDrawSequence(const uint16 poly);
106 bool LoadGlyphFromFile(FILE *);
107 bool SaveGlyphToFile(FILE *);
110 void AllocateAndCopy(int, int, int *, int *, bool *, uint16 *);
111 void FreeAllocatedMemory(void);
114 int numPoints, numPolys;
118 uint16 pointsAllocated, polysAllocated;
121 #endif // __GLYPHPOINTS_H__