Commit 9aa9fe44fe7d44cfcd15d9520a7172d4d46e160b

henry 2001-08-19T22:31:25

Implemented charmap, CharIndex and kernAdvance functions. These are now wrappers for the freetype functions and the rest of FTGL should not call freetype directly.

diff --git a/include/FTFace.h b/include/FTFace.h
index 3c3c9fd..9e56b2a 100755
--- a/include/FTFace.h
+++ b/include/FTFace.h
@@ -19,10 +19,10 @@ class	FTFace
 		virtual ~FTFace();
 		bool Open( const char* filename);
 		void Close();
-		FTSize& Size( const int size, const int res );
-		bool CharMap( CHARMAP encoding );
-		FT_Glyph Glyph( int index );
-		FT_Vector KernAdvance( int index1, int index2 );
+		FTSize& Size( const int size, const int res);
+		bool CharMap( FT_Encoding encoding);
+		int CharIndex( int index ) const;
+		FT_Vector& KernAdvance( int index1, int index2);
 		FT_Face* Face() const { return ftFace;}
 		
 		FT_Error Error() const { return err;}
@@ -36,9 +36,12 @@ class	FTFace
 		FT_Error err;
 		FTSize	charSize;
 		FT_Face* ftFace;
+		
 		int	numCharMaps;
 		int	numGlyphs;
 		
+		FT_Vector kernAdvance;
+		
 };
 
 
diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index 875edd4..1906dbe 100755
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -52,26 +52,41 @@ FTSize& FTFace::Size( const int size, const int res )
 }
 
 
-bool FTFace::CharMap( CHARMAP encoding )
+bool FTFace::CharMap( FT_Encoding encoding )
 {
-//Insert your own code here.
-
-//End of user code.   
-	return false;     
+// 	ft_encoding_none, 0, 0, 0, 0
+// 	ft_encoding_symbol,  's', 'y', 'm', 'b'
+// 	ft_encoding_unicode, 'u', 'n', 'i', 'c'
+// 	ft_encoding_latin_2, 'l', 'a', 't', '2'
+// 	ft_encoding_sjis,    's', 'j', 'i', 's'
+// 	ft_encoding_gb2312,  'g', 'b', ' ', ' '
+// 	ft_encoding_big5,    'b', 'i', 'g', '5'
+// 	ft_encoding_wansung, 'w', 'a', 'n', 's'
+// 	ft_encoding_johab,   'j', 'o', 'h', 'a'
+// 	ft_encoding_adobe_standard, 'A', 'D', 'O', 'B'
+// 	ft_encoding_adobe_expert,   'A', 'D', 'B', 'E'
+// 	ft_encoding_adobe_custom,   'A', 'D', 'B', 'C'
+// 	ft_encoding_apple_roman, 'a', 'r', 'm', 'n'
+	
+	err = FT_Select_Charmap( *ftFace, encoding );
+	return !err;
 }
 
 
-FT_Glyph FTFace::Glyph( int index )
+int FTFace::CharIndex( int index ) const
 {
-//Insert your own code here.
-
-//End of user code.         
+	return FT_Get_Char_Index( *ftFace, index);
 }
 
 
-FT_Vector FTFace::KernAdvance( int index1, int index2 )
+FT_Vector& FTFace::KernAdvance( int index1, int index2 )
 {
-//Insert your own code here.
-
-//End of user code.         
+	kernAdvance.x = 0; kernAdvance.y = 0;
+	
+	if( FT_HAS_KERNING((*ftFace)) && index1 && index2)
+	{
+		err = FT_Get_Kerning( *ftFace, index1, index2, ft_kerning_unfitted, &kernAdvance);	
+	}
+	
+	return kernAdvance;
 }