Commit 558889827bbd2d883b68bf0ba133043cf87f70fa

henry 2004-10-17T00:40:24

Changed advance to be an FTPoint rather than a float.

diff --git a/include/FTBitmapGlyph.h b/include/FTBitmapGlyph.h
index 89154a9..a9909df 100755
--- a/include/FTBitmapGlyph.h
+++ b/include/FTBitmapGlyph.h
@@ -41,7 +41,7 @@ class FTGL_EXPORT FTBitmapGlyph : public FTGlyph
          * @param pen   The current pen position.
          * @return      The advance distance for this glyph.
          */
-        virtual float Render( const FTPoint& pen);
+        virtual const FTPoint& Render( const FTPoint& pen);
         
     private:
         /**
diff --git a/include/FTExtrdGlyph.h b/include/FTExtrdGlyph.h
index d1d9d87..135b25a 100644
--- a/include/FTExtrdGlyph.h
+++ b/include/FTExtrdGlyph.h
@@ -43,7 +43,7 @@ class FTGL_EXPORT FTExtrdGlyph : public FTGlyph
          * @param pen   The current pen position.
          * @return      The advance distance for this glyph.
          */
-        virtual float Render( const FTPoint& pen);
+        virtual const FTPoint& Render( const FTPoint& pen);
         
     private:
         /**
diff --git a/include/FTGlyph.h b/include/FTGlyph.h
index 2083964..b4bef08 100755
--- a/include/FTGlyph.h
+++ b/include/FTGlyph.h
@@ -46,14 +46,14 @@ class FTGL_EXPORT FTGlyph
          * @param pen   The current pen position.
          * @return      The advance distance for this glyph.
          */
-        virtual float Render( const FTPoint& pen) = 0;
+        virtual const FTPoint& Render( const FTPoint& pen) = 0;
         
         /**
          * Return the advance width for this glyph.
          *
          * @return  advance width.
          */
-        float Advance() const { return advance;}
+        const FTPoint& Advance() const { return advance;}
         
         /**
          * Return the bounding box for this glyph.
@@ -73,7 +73,7 @@ class FTGL_EXPORT FTGlyph
         /**
          * The advance distance for this glyph
          */
-        float advance;
+        FTPoint advance;
 
         /**
          * The bounding box of this glyph.
diff --git a/include/FTOutlineGlyph.h b/include/FTOutlineGlyph.h
index 0333d56..3e3578c 100644
--- a/include/FTOutlineGlyph.h
+++ b/include/FTOutlineGlyph.h
@@ -42,7 +42,7 @@ class FTGL_EXPORT FTOutlineGlyph : public FTGlyph
          * @param pen	The current pen position.
          * @return		The advance distance for this glyph.
          */
-        virtual float Render( const FTPoint& pen);
+        virtual const FTPoint& Render( const FTPoint& pen);
         
     private:		
         /**
diff --git a/include/FTPixmapGlyph.h b/include/FTPixmapGlyph.h
index 9d43d6c..5039346 100755
--- a/include/FTPixmapGlyph.h
+++ b/include/FTPixmapGlyph.h
@@ -37,7 +37,7 @@ class  FTGL_EXPORT FTPixmapGlyph : public FTGlyph
          * @param pen   The current pen position.
          * @return      The advance distance for this glyph.
          */
-        virtual float Render( const FTPoint& pen);
+        virtual const FTPoint& Render( const FTPoint& pen);
         
         // attributes
 
diff --git a/include/FTPoint.h b/include/FTPoint.h
index d9e3305..ce6c025 100755
--- a/include/FTPoint.h
+++ b/include/FTPoint.h
@@ -105,7 +105,7 @@ class FTGL_EXPORT FTPoint
          * @param multiplier
          * @return <code>multiplier</code> multiplied by <code>point</code>.
          */
-        friend FTPoint operator*( double multiplier, const FTPoint& point);
+        friend FTPoint operator*( double multiplier, FTPoint& point);
 
 
         /**
diff --git a/include/FTPolyGlyph.h b/include/FTPolyGlyph.h
index bd25d6d..9cd3dcf 100644
--- a/include/FTPolyGlyph.h
+++ b/include/FTPolyGlyph.h
@@ -44,7 +44,7 @@ class FTGL_EXPORT FTPolyGlyph : public FTGlyph
          * @param pen   The current pen position.
          * @return      The advance distance for this glyph.
          */
-        virtual float Render( const FTPoint& pen);
+        virtual const FTPoint& Render( const FTPoint& pen);
         
     private:
         /**
diff --git a/include/FTTextureGlyph.h b/include/FTTextureGlyph.h
index bff82c9..c263f72 100755
--- a/include/FTTextureGlyph.h
+++ b/include/FTTextureGlyph.h
@@ -46,7 +46,7 @@ class FTGL_EXPORT FTTextureGlyph : public FTGlyph
          * @param pen   The current pen position.
          * @return      The advance distance for this glyph.
          */
-        virtual float Render( const FTPoint& pen);
+        virtual const FTPoint& Render( const FTPoint& pen);
         
         /**
          * Reset the currently active texture to zero to get into a known state before
diff --git a/src/FTBitmapGlyph.cpp b/src/FTBitmapGlyph.cpp
index d0c0fd9..f37ef10 100755
--- a/src/FTBitmapGlyph.cpp
+++ b/src/FTBitmapGlyph.cpp
@@ -49,7 +49,7 @@ FTBitmapGlyph::~FTBitmapGlyph()
 }
 
 
-float FTBitmapGlyph::Render( const FTPoint& pen)
+const FTPoint& FTBitmapGlyph::Render( const FTPoint& pen)
 {
     glBitmap( 0, 0, 0.0f, 0.0f, pen.X() + pos.X(), pen.Y() - pos.Y(), (const GLubyte*)0 );
     
diff --git a/src/FTExtrdGlyph.cpp b/src/FTExtrdGlyph.cpp
index 859834d..7696c4c 100644
--- a/src/FTExtrdGlyph.cpp
+++ b/src/FTExtrdGlyph.cpp
@@ -135,7 +135,7 @@ FTExtrdGlyph::~FTExtrdGlyph()
 }
 
 
-float FTExtrdGlyph::Render( const FTPoint& pen)
+const FTPoint& FTExtrdGlyph::Render( const FTPoint& pen)
 {
     glTranslatef( pen.X(), pen.Y(), 0);
     
diff --git a/src/FTGlyph.cpp b/src/FTGlyph.cpp
index 8f3373b..d969bdd 100755
--- a/src/FTGlyph.cpp
+++ b/src/FTGlyph.cpp
@@ -2,14 +2,13 @@
 
 
 FTGlyph::FTGlyph( FT_GlyphSlot glyph, bool useList)
-:   advance(0.0f),
-    useDisplayList(useList),
+:   useDisplayList(useList),
     err(0)  
 {
     if( glyph)
     {
         bBox = FTBBox( glyph);
-        advance = static_cast<float>( glyph->advance.x) / 64.0f;
+        advance = FTPoint( glyph->advance.x / 64.0f, glyph->advance.y / 64.0f, 0.0f);
     }
 }
 
diff --git a/src/FTGlyphContainer.cpp b/src/FTGlyphContainer.cpp
index 6c498f6..7b088de 100755
--- a/src/FTGlyphContainer.cpp
+++ b/src/FTGlyphContainer.cpp
@@ -66,7 +66,7 @@ float FTGlyphContainer::Advance( const unsigned int characterCode, const unsigne
     unsigned int right = charMap->FontIndex( nextCharacterCode);
 
     float width = face->KernAdvance( left, right).X();
-    width += glyphs[charMap->GlyphListIndex( characterCode)]->Advance();
+    width += glyphs[charMap->GlyphListIndex( characterCode)]->Advance().X();
     
     return width;
 }
@@ -74,8 +74,7 @@ float FTGlyphContainer::Advance( const unsigned int characterCode, const unsigne
 
 FTPoint FTGlyphContainer::Render( const unsigned int characterCode, const unsigned int nextCharacterCode, FTPoint penPosition)
 {
-    FTPoint kernAdvance;
-    float advance = 0;
+    FTPoint kernAdvance, advance;
     
     unsigned int left = charMap->FontIndex( characterCode);
     unsigned int right = charMap->FontIndex( nextCharacterCode);
@@ -87,7 +86,6 @@ FTPoint FTGlyphContainer::Render( const unsigned int characterCode, const unsign
         advance = glyphs[charMap->GlyphListIndex( characterCode)]->Render( penPosition);
     }
     
-    kernAdvance.X( advance + kernAdvance.X());
-//  kernAdvance.Y( advance.y + kernAdvance.X());
+    kernAdvance += advance;
     return kernAdvance;
 }
diff --git a/src/FTOutlineGlyph.cpp b/src/FTOutlineGlyph.cpp
index 1a0fe44..d642756 100644
--- a/src/FTOutlineGlyph.cpp
+++ b/src/FTOutlineGlyph.cpp
@@ -52,7 +52,7 @@ FTOutlineGlyph::~FTOutlineGlyph()
 }
 
 
-float FTOutlineGlyph::Render( const FTPoint& pen)
+const FTPoint& FTOutlineGlyph::Render( const FTPoint& pen)
 {
     glTranslatef( pen.X(), pen.Y(), 0.0f);
 
diff --git a/src/FTPixmapGlyph.cpp b/src/FTPixmapGlyph.cpp
index a8ecd6c..bd04bf7 100755
--- a/src/FTPixmapGlyph.cpp
+++ b/src/FTPixmapGlyph.cpp
@@ -83,7 +83,7 @@ FTPixmapGlyph::~FTPixmapGlyph()
 }
 
 
-float FTPixmapGlyph::Render( const FTPoint& pen)
+const FTPoint& FTPixmapGlyph::Render( const FTPoint& pen)
 {
     glBitmap( 0, 0, 0.0f, 0.0f, pen.X() + pos.X(), pen.Y() - pos.Y(), (const GLubyte*)0);
     
diff --git a/src/FTPoint.cpp b/src/FTPoint.cpp
index 04d8cdd..5a48c2a 100755
--- a/src/FTPoint.cpp
+++ b/src/FTPoint.cpp
@@ -12,7 +12,7 @@ bool operator != ( const FTPoint &a, const FTPoint &b)
 }
 
 
-FTPoint operator*( double multiplier, const FTPoint& point)
+FTPoint operator*( double multiplier, FTPoint& point)
 {
         return point * multiplier;
 }
diff --git a/src/FTPolyGlyph.cpp b/src/FTPolyGlyph.cpp
index 845b1c9..1e69f40 100644
--- a/src/FTPolyGlyph.cpp
+++ b/src/FTPolyGlyph.cpp
@@ -64,7 +64,7 @@ FTPolyGlyph::~FTPolyGlyph()
 }
 
 
-float FTPolyGlyph::Render( const FTPoint& pen)
+const FTPoint& FTPolyGlyph::Render( const FTPoint& pen)
 {
     glTranslatef(  pen.X(),  pen.Y(), 0.0f);
 
diff --git a/src/FTTextureGlyph.cpp b/src/FTTextureGlyph.cpp
index 3f21cde..7bf6e32 100755
--- a/src/FTTextureGlyph.cpp
+++ b/src/FTTextureGlyph.cpp
@@ -55,7 +55,7 @@ FTTextureGlyph::~FTTextureGlyph()
 {}
 
 
-float FTTextureGlyph::Render( const FTPoint& pen)
+const FTPoint& FTTextureGlyph::Render( const FTPoint& pen)
 {
     if( activeTextureID != glTextureID)
     {
diff --git a/test/FTFont-Test.cpp b/test/FTFont-Test.cpp
index d11852f..8ad9f21 100755
--- a/test/FTFont-Test.cpp
+++ b/test/FTFont-Test.cpp
@@ -15,7 +15,7 @@ class TestGlyph : public FTGlyph
         :   FTGlyph( glyph)
         {}
         
-        float Render( const FTPoint& pen){ return advance;}
+        const FTPoint& Render( const FTPoint& pen){ return advance;}
 };
 
 
diff --git a/test/FTGlyph-Test.cpp b/test/FTGlyph-Test.cpp
index 0a4bf1f..a8d9364 100755
--- a/test/FTGlyph-Test.cpp
+++ b/test/FTGlyph-Test.cpp
@@ -13,7 +13,7 @@ class TestGlyph : public FTGlyph
         :   FTGlyph(glyph)
         {}
         
-        float Render( const FTPoint& pen) { return 0.0f;};
+        const FTPoint& Render( const FTPoint& pen) { return advance;};
 };
 
 
@@ -34,7 +34,9 @@ class FTGlyphTest : public CppUnit::TestCase
         {            
             TestGlyph testGlyph(0);
             
-            CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, testGlyph.Advance(), 0.01);
+            FTPoint testPoint;
+
+            CPPUNIT_ASSERT( testPoint == testGlyph.Advance());
 
             CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, testGlyph.BBox().upperY, 0.01);
         
@@ -47,7 +49,9 @@ class FTGlyphTest : public CppUnit::TestCase
             setUpFreetype( CHARACTER_CODE_A);
             TestGlyph testGlyph(face->glyph);
             
-            CPPUNIT_ASSERT_DOUBLES_EQUAL( 47, testGlyph.Advance(), 0.01);
+            FTPoint testPoint(47.0f, 0.0f, 0.0f);
+            
+            CPPUNIT_ASSERT( testPoint == testGlyph.Advance());
 
             CPPUNIT_ASSERT_DOUBLES_EQUAL( 51.39, testGlyph.BBox().upperY, 0.01);
         
diff --git a/test/FTGlyphContainer-Test.cpp b/test/FTGlyphContainer-Test.cpp
index 1134941..9ade50f 100755
--- a/test/FTGlyphContainer-Test.cpp
+++ b/test/FTGlyphContainer-Test.cpp
@@ -16,10 +16,10 @@ class TestGlyph : public FTGlyph
         TestGlyph()
         :   FTGlyph(0)
         {
-            advance = 50.0f;
+            advance = FTPoint(50.0f, 0.0f, 0.0f);
         }
         
-        virtual float Render( const FTPoint& pen){ return advance;}
+        virtual const FTPoint& Render( const FTPoint& pen){ return advance;}
 };