Implemented charmap, CharIndex and kernAdvance functions. These are now wrappers for the freetype functions and the rest of FTGL should not call freetype directly.
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
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;
}