Commit 73e3a4ad9d3631b6732f4619628d9e7fe35d8ffe

henry 2002-12-11T09:28:01

Removed redundant members. Moved BBox and advance to FTGlyph c_stor

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;