This now uses FTFace function rather than calling freetype directly...better encapsulation and may allow future caching.
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
diff --git a/include/FTGlyphContainer.h b/include/FTGlyphContainer.h
index 8185447..b18c9f6 100755
--- a/include/FTGlyphContainer.h
+++ b/include/FTGlyphContainer.h
@@ -8,7 +8,7 @@
#include FT_GLYPH_H
//#include "FTGL.h"
-
+class FTFace;
class FTGlyph;
using namespace std;
@@ -17,7 +17,7 @@ class FTGlyphContainer
{
public:
// methods
- FTGlyphContainer( FT_Face* face, int numGlyphs, bool p = false);
+ FTGlyphContainer( FTFace* face, int numGlyphs, bool p = false);
~FTGlyphContainer();
bool Add( FTGlyph* tempGlyph);
@@ -33,8 +33,7 @@ class FTGlyphContainer
FT_Error err;
bool preCache;
int numGlyphs;
- FTGlyph* tempGlyph;
- FT_Face* face;
+ FTFace* face;
FT_Vector kernAdvance;
float advance;
diff --git a/src/FTGlyphContainer.cpp b/src/FTGlyphContainer.cpp
index 3dd6d64..7f00e44 100755
--- a/src/FTGlyphContainer.cpp
+++ b/src/FTGlyphContainer.cpp
@@ -1,11 +1,11 @@
#include "FTGlyphContainer.h"
#include "FTGlyph.h"
+#include "FTFace.h"
-FTGlyphContainer::FTGlyphContainer( FT_Face* f, int g, bool p)
+FTGlyphContainer::FTGlyphContainer( FTFace* f, int g, bool p)
: preCache( p),
numGlyphs(g),
- tempGlyph(0),
face(f)
{
glyphs.reserve( g);
@@ -27,7 +27,9 @@ FTGlyphContainer::~FTGlyphContainer()
bool FTGlyphContainer::Add( FTGlyph* tempGlyph)
{
+ // At the moment we are using a vector. Vectors don't return bool.
glyphs.push_back( tempGlyph);
+ return true;
}
@@ -35,19 +37,12 @@ FT_Vector& FTGlyphContainer::render( int index, int next, FT_Vector pen)
{
kernAdvance.x = 0; kernAdvance.y = 0;
- int left = FT_Get_Char_Index( *face, index);
- int right = FT_Get_Char_Index( *face, next);
+ int left = face->CharIndex( index);
+ int right = face->CharIndex( next);
- if( left > glyphs.size())
- return kernAdvance;
-
- if( 0 < right <= glyphs.size())
- {
- // ft_kerning_unfitted
- err = FT_Get_Kerning( *face, left, right, ft_kerning_default, &kernAdvance);
- }
-
- advance = glyphs[left]->Render( pen);
+ kernAdvance = face->KernAdvance( left, right);
+ if( !face->Error())
+ advance = glyphs[left]->Render( pen);
kernAdvance.x = advance + kernAdvance.x;
// kernAdvance.y = advance.y + kernAdvance.y;