Removed redundant members. Moved BBox and advance to FTGlyph c_stor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
diff --git a/include/FTExtrdGlyph.h b/include/FTExtrdGlyph.h
index e3e8a8c..324287e 100644
--- a/include/FTExtrdGlyph.h
+++ b/include/FTExtrdGlyph.h
@@ -44,14 +44,6 @@ class FTGL_EXPORT FTExtrdGlyph : public FTGlyph
private:
/**
- * Calculate the winding direction of a contour.
- *
- * This uses the signed area of the contour. It is required because
- * freetype doesn't do this despite the docs saying it does:(
- */
- bool Winding( int numPoints, FTGL_DOUBLE *points);
-
- /**
* OpenGL display list
*/
GLuint glList;
diff --git a/include/FTGlyph.h b/include/FTGlyph.h
index c5c1c19..268defc 100755
--- a/include/FTGlyph.h
+++ b/include/FTGlyph.h
@@ -28,7 +28,7 @@ class FTGL_EXPORT FTGlyph
/**
* Constructor
*/
- FTGlyph();
+ FTGlyph( FT_Glyph glyph);
/**
* Destructor
diff --git a/include/FTOutlineGlyph.h b/include/FTOutlineGlyph.h
index 6b22b7a..ba7aae1 100644
--- a/include/FTOutlineGlyph.h
+++ b/include/FTOutlineGlyph.h
@@ -41,22 +41,7 @@ class FTGL_EXPORT FTOutlineGlyph : public FTGlyph
*/
virtual float Render( const FTPoint& pen);
- private:
- /**
- * The total number of points in the Freetype outline
- */
- int numPoints;
-
- /**
- * The totals number of contours in the Freetype outline
- */
- int numContours;
-
- /**
- * Pointer to the point data
- */
- FTGL_DOUBLE* data;
-
+ private:
/**
* OpenGL display list
*/
diff --git a/include/FTPolyGlyph.h b/include/FTPolyGlyph.h
index f85f84d..d6229af 100644
--- a/include/FTPolyGlyph.h
+++ b/include/FTPolyGlyph.h
@@ -44,23 +44,6 @@ class FTGL_EXPORT FTPolyGlyph : public FTGlyph
private:
/**
- * Convert the point data into a mesh.
- *
- * Uses GLUtesselator to create a mesh
- */
- void Tesselate();
-
- /**
- * The total number of points in the Freetype outline
- */
- int numPoints;
-
- /**
- * Pointer to the point data
- */
- FTGL_DOUBLE* data;
-
- /**
* OpenGL display list
*/
GLuint glList;
diff --git a/src/FTBitmapGlyph.cpp b/src/FTBitmapGlyph.cpp
index 56957b8..8ff3dbf 100755
--- a/src/FTBitmapGlyph.cpp
+++ b/src/FTBitmapGlyph.cpp
@@ -1,7 +1,7 @@
#include "FTBitmapGlyph.h"
FTBitmapGlyph::FTBitmapGlyph( FT_Glyph glyph)
-: FTGlyph(),
+: FTGlyph( glyph),
destWidth(0),
destHeight(0),
data(0)
@@ -46,8 +46,6 @@ FTBitmapGlyph::FTBitmapGlyph( FT_Glyph glyph)
}
}
- bBox = FTBBox( glyph);
- advance = static_cast<float>(glyph->advance.x >> 16);
pos.x = bitmap->left;
pos.y = static_cast<int>(srcHeight) - bitmap->top;
diff --git a/src/FTExtrdGlyph.cpp b/src/FTExtrdGlyph.cpp
index f8c2dc2..6f9662c 100644
--- a/src/FTExtrdGlyph.cpp
+++ b/src/FTExtrdGlyph.cpp
@@ -5,7 +5,7 @@
FTExtrdGlyph::FTExtrdGlyph( FT_Glyph glyph, float d)
-: FTGlyph(),
+: FTGlyph( glyph),
glList(0),
depth(d)
{
@@ -25,7 +25,7 @@ FTExtrdGlyph::FTExtrdGlyph( FT_Glyph glyph, float d)
bBox.upperZ = -depth;
advance = glyph->advance.x >> 16;
- int numPoints = vectoriser->MeshPoints();
+ unsigned int numPoints = vectoriser->MeshPoints();
if ( numPoints < 3)
{
delete vectoriser;
@@ -131,7 +131,7 @@ FTExtrdGlyph::FTExtrdGlyph( FT_Glyph glyph, float d)
glBegin( GL_QUAD_STRIP);
- for( int j= 0; j <= numPoints; ++j)
+ for( unsigned int j= 0; j <= numPoints; ++j)
{
int j1 = (j < numPoints) ? j : 0;
int j0 = (j1 == 0) ? (numPoints-1) : (j1-1);
@@ -182,26 +182,6 @@ FTExtrdGlyph::~FTExtrdGlyph()
{}
-bool FTExtrdGlyph::Winding( int numPoints, FTGL_DOUBLE *points)
-{
- // Calculate the winding direction. use formula from redbook.
- FTGL_DOUBLE area = 0;
-
- for( int count = 0; count <= numPoints; ++count)
- {
- int j1 = (count < numPoints) ? count : 0;
- int j0 = (j1 == 0) ? ( numPoints - 1) : ( j1 - 1);
-
- FTGL_DOUBLE* p0 = points + j0 * 3;
- FTGL_DOUBLE* p1 = points + j1 * 3;
-
- area += ( p0[0] * p1[1]) - ( p1[0] * p0[1]);
- }
-
- return( area >= 0 );
-}
-
-
float FTExtrdGlyph::Render( const FTPoint& pen)
{
if( glList)
diff --git a/src/FTGlyph.cpp b/src/FTGlyph.cpp
index c3bf403..aa8a51e 100755
--- a/src/FTGlyph.cpp
+++ b/src/FTGlyph.cpp
@@ -1,10 +1,16 @@
#include "FTGlyph.h"
-FTGlyph::FTGlyph()
+FTGlyph::FTGlyph( FT_Glyph glyph)
: advance(0.0f),
err(0)
-{}
+{
+ if( glyph)
+ {
+ bBox = FTBBox( glyph);
+ advance = static_cast<float>( glyph->advance.x) / 65536.0f;
+ }
+}
FTGlyph::~FTGlyph()
diff --git a/src/FTOutlineGlyph.cpp b/src/FTOutlineGlyph.cpp
index f09ff0b..6bcf3f6 100644
--- a/src/FTOutlineGlyph.cpp
+++ b/src/FTOutlineGlyph.cpp
@@ -3,10 +3,7 @@
FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
-: FTGlyph(),
- numPoints(0),
- numContours(0),
- data(0),
+: FTGlyph( glyph),
glList(0)
{
if( ft_glyph_format_outline != glyph->format)
@@ -18,11 +15,8 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
vectoriser->ProcessContours();
- numPoints = vectoriser->points();
- numContours = vectoriser->contours();
-
- bBox = FTBBox( glyph);
- advance = glyph->advance.x >> 16;
+ unsigned int numPoints = vectoriser->points();
+ unsigned int numContours = vectoriser->contours();
if ( ( numContours < 1) || ( numPoints < 3))
{
@@ -30,13 +24,13 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
return;
}
- data = new FTGL_DOUBLE[ numPoints * 3];
+ FTGL_DOUBLE* data = new FTGL_DOUBLE[ numPoints * 3];
vectoriser->GetOutline( data);
int d = 0;
glList = glGenLists(1);
glNewList( glList, GL_COMPILE);
- for( int c = 0; c < numContours; ++c)
+ for( unsigned int c = 0; c < numContours; ++c)
{
glBegin( GL_LINE_LOOP);
int contourLength = vectoriser->contourSize( c);
diff --git a/src/FTPixmapGlyph.cpp b/src/FTPixmapGlyph.cpp
index 77c7a83..c07a283 100755
--- a/src/FTPixmapGlyph.cpp
+++ b/src/FTPixmapGlyph.cpp
@@ -1,7 +1,7 @@
#include "FTPixmapGlyph.h"
FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph)
-: FTGlyph(),
+: FTGlyph( glyph),
destWidth(0),
destHeight(0),
numGreys(0),
@@ -75,10 +75,8 @@ FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph)
destHeight = srcHeight;
}
-
- bBox = FTBBox( glyph);
+
numGreys = source->num_grays;
- advance = glyph->advance.x >> 16;
pos.x = bitmap->left;
pos.y = srcHeight - bitmap->top;
diff --git a/src/FTPolyGlyph.cpp b/src/FTPolyGlyph.cpp
index 20afade..f47522c 100644
--- a/src/FTPolyGlyph.cpp
+++ b/src/FTPolyGlyph.cpp
@@ -3,9 +3,7 @@
FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
-: FTGlyph(),
- numPoints(0),
- data(0),
+: FTGlyph( glyph),
glList(0)
{
if( ft_glyph_format_outline != glyph->format)
@@ -18,10 +16,7 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
vectoriser->ProcessContours();
vectoriser->MakeMesh(1.0);
- numPoints = vectoriser->MeshPoints();
-
- bBox = FTBBox( glyph);
- advance = glyph->advance.x >> 16;
+ unsigned int numPoints = vectoriser->MeshPoints();
if( numPoints < 3)
{
@@ -29,7 +24,7 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
return;
}
- data = new FTGL_DOUBLE[ numPoints * 3];
+ FTGL_DOUBLE* data = new FTGL_DOUBLE[ numPoints * 3];
vectoriser->GetMesh( data);
delete vectoriser;
diff --git a/src/FTTextureGlyph.cpp b/src/FTTextureGlyph.cpp
index f0c636b..a631960 100755
--- a/src/FTTextureGlyph.cpp
+++ b/src/FTTextureGlyph.cpp
@@ -2,7 +2,7 @@
FTTextureGlyph::FTTextureGlyph( FT_Glyph glyph, int id, int xOffset, int yOffset, GLsizei width, GLsizei height)
-: FTGlyph(),
+: FTGlyph( glyph),
destWidth(0),
destHeight(0),
numGreys(0),
@@ -48,8 +48,6 @@ FTTextureGlyph::FTTextureGlyph( FT_Glyph glyph, int id, int xOffset, int yOffset
uv[1].y = static_cast<float>( yOffset + destHeight) / static_cast<float>(height);
numGreys = source->num_grays;
- advance = glyph->advance.x >> 16;
- bBox = FTBBox( glyph);
pos.x = bitmap->left;
pos.y = bitmap->top;