Commit d0651fb64112adfa062bc29725a3047d8984f5b5

sammy 2008-04-25T09:59:11

* Fix random bugs introduced in [941] and [943].

diff --git a/include/FTContour.h b/include/FTContour.h
index ba86187..c27934d 100644
--- a/include/FTContour.h
+++ b/include/FTContour.h
@@ -68,6 +68,9 @@ class FTGL_EXPORT FTContour
         ~FTContour()
         {
             pointList.clear();
+            outsetPointList.clear();
+            frontPointList.clear();
+            backPointList.clear();
         }
 
         /**
@@ -125,6 +128,7 @@ class FTGL_EXPORT FTContour
          *
          * @return the number of points in this contour
          */
+        size_t OutsetPointCount() const { return outsetPointList.size(); }
         size_t FrontPointCount() const { return frontPointList.size(); }
         size_t BackPointCount() const { return backPointList.size(); }
 
diff --git a/src/FTContour.cpp b/src/FTContour.cpp
index 58156cc..ff59a31 100644
--- a/src/FTContour.cpp
+++ b/src/FTContour.cpp
@@ -52,13 +52,22 @@ void FTContour::AddPoint(FTPoint point)
     }
 }
 
+
 void FTContour::AddOutsetPoint(FTPoint point)
 {
-    if(outsetPointList.empty() || (point != outsetPointList[pointList.size() - 1]
-                              && point != outsetPointList[0]))
-    {
-        outsetPointList.push_back(point);
-    }
+    outsetPointList.push_back(point);
+}
+
+
+void FTContour::AddFrontPoint(FTPoint point)
+{
+    frontPointList.push_back(point);
+}
+
+
+void FTContour::AddBackPoint(FTPoint point)
+{
+    backPointList.push_back(point);
 }
 
 
@@ -92,24 +101,6 @@ void FTContour::evaluateCubicCurve(FTPoint A, FTPoint B, FTPoint C, FTPoint D)
     }
 }
 
-void FTContour::AddFrontPoint(FTPoint point)
-{
-    if(frontPointList.empty() || (point != frontPointList[pointList.size() - 1]
-                                   && point != frontPointList[0]))
-    {
-        frontPointList.push_back(point);
-    }
-}
-
-void FTContour::AddBackPoint(FTPoint point)
-{
-    if(backPointList.empty() || (point != backPointList[pointList.size() - 1]
-                                  && point != backPointList[0]))
-    {
-        backPointList.push_back(point);
-    }
-}
-
 FTGL_DOUBLE FTContour::NormVector(const FTPoint &v)
 {
     return sqrt(v.X() * v.X() + v.Y() * v.Y());
@@ -136,9 +127,9 @@ void FTContour::MultMatrixVect(FTGL_DOUBLE *mat, FTPoint &v)
 
 void FTContour::ComputeBisec(FTPoint &v)
 {
-    FTGL_DOUBLE sgn = 64.0;
+    FTGL_DOUBLE sgn = -64.0;
     if((v.Y() / NormVector(v)) < 0)
-        sgn = -64.0;
+        sgn = 64.0;
     v.X(sgn * sqrt((NormVector(v) - v.X()) / (NormVector(v) + v.X())));
     v.Y(64.0);
 }
@@ -162,15 +153,15 @@ FTPoint FTContour::ComputeOutsetPoint(FTPoint a, FTPoint b, FTPoint c)
 void FTContour::outsetContour()
 {
     size_t size = PointCount();
-    FTPoint vOutsetF, vOutsetB;
+    FTPoint vOutset;
     for(unsigned int pointIndex = 0; pointIndex < size; ++pointIndex)
     {
         int prev = (pointIndex%size + size - 1) % size;
         int cur = pointIndex%size;
         int next = (pointIndex%size + 1) % size;
         /* Build the outset shape with d = 1.0f */
-        vOutsetB = ComputeOutsetPoint(Point(prev), Point(cur), Point(next));
-        AddOutsetPoint(vOutsetB);
+        vOutset = ComputeOutsetPoint(Point(prev), Point(cur), Point(next));
+        AddOutsetPoint(vOutset);
     }
 }
 
@@ -219,7 +210,6 @@ FTContour::FTContour(FT_Vector* contour, char* tags, unsigned int n)
             FTPoint next2 = (i == n - 2)
                              ? pointList[0]
                              : FTPoint(contour[i + 2]);
-
             evaluateCubicCurve(prev, cur, next, next2);
             ++i;
             continue;
diff --git a/src/FTOutlineGlyph.cpp b/src/FTOutlineGlyph.cpp
index 0ad798b..8a55351 100644
--- a/src/FTOutlineGlyph.cpp
+++ b/src/FTOutlineGlyph.cpp
@@ -59,7 +59,7 @@ FTOutlineGlyph::FTOutlineGlyph(FT_GlyphSlot glyph, float _outset,
         return;
     }
 
-    this->outset = outset;
+    outset = _outset;
 
     if(useDisplayList)
     {
diff --git a/src/FTPoint.cpp b/src/FTPoint.cpp
index ea7f6d6..21a281b 100644
--- a/src/FTPoint.cpp
+++ b/src/FTPoint.cpp
@@ -38,12 +38,12 @@
 
 #include <math.h>
 
-bool operator == ( const FTPoint &a, const FTPoint &b) 
+bool operator == ( const FTPoint &a, const FTPoint &b)
 {
     return((a.values[0] == b.values[0]) && (a.values[1] == b.values[1]) && (a.values[2] == b.values[2]));
 }
 
-bool operator != ( const FTPoint &a, const FTPoint &b) 
+bool operator != ( const FTPoint &a, const FTPoint &b)
 {
     return((a.values[0] != b.values[0]) || (a.values[1] != b.values[1]) || (a.values[2] != b.values[2]));
 }
@@ -53,7 +53,7 @@ FTPoint operator*( double multiplier, FTPoint& point)
 {
     return point * multiplier;
 }
-        
+
 FTPoint FTPoint::GetNormal(const FTPoint &a, const FTPoint &b)
 {
     float vectorX = a.X() - b.X();
diff --git a/src/FTPolyGlyph.cpp b/src/FTPolyGlyph.cpp
index 6347037..aeb241f 100644
--- a/src/FTPolyGlyph.cpp
+++ b/src/FTPolyGlyph.cpp
@@ -60,9 +60,9 @@ FTPolyGlyph::FTPolyGlyph(FT_GlyphSlot glyph, float _outset,
     }
 
 
-    this->hscale = glyph->face->size->metrics.x_ppem * 64;
-    this->vscale = glyph->face->size->metrics.y_ppem * 64;
-    this->outset = outset;
+    hscale = glyph->face->size->metrics.x_ppem * 64;
+    vscale = glyph->face->size->metrics.y_ppem * 64;
+    outset = _outset;
 
     if(useDisplayList)
     {