Commit 31fa83cb620dc5deb9762f04fdff1686b43cfbc1

henry 2001-08-19T22:34:40

This now uses FTFace function rather than calling freetype directly...better encapsulation and may allow future caching.

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;