Changed advance to be an FTPoint rather than a float.
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 321 322 323 324 325 326 327 328 329 330
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;}
};