Commit 262b30a5905e8eca2bc19d2102d922ef99db10f8

henry 2001-09-17T20:59:34

Implemented FTCharmap class

diff --git a/include/FTFace.h b/include/FTFace.h
index 8e564bb..9ba7514 100755
--- a/include/FTFace.h
+++ b/include/FTFace.h
@@ -9,6 +9,8 @@
 
 #include "FTSize.h"
 
+class FTCharmap;
+
 /**
  * FTFace class provides an abstraction layer for the Freetype Face.
  *
@@ -18,7 +20,6 @@
 class	FTFace
 {
 	public:
-		// methods
 		/**
 		 * Default Constructor
 		 */
@@ -59,20 +60,6 @@ class	FTFace
 
 		/**
 		 * Sets the character map for the face.
-		 * Valid encodings as at Freetype 2.0.4
-		 *		ft_encoding_none
-		 *		ft_encoding_symbol
-		 *		ft_encoding_unicode
-		 *		ft_encoding_latin_2
-		 *		ft_encoding_sjis
-		 *		ft_encoding_gb2312
-		 *		ft_encoding_big5
-		 *		ft_encoding_wansung
-		 *		ft_encoding_johab
-		 *		ft_encoding_adobe_standard
-		 *		ft_encoding_adobe_expert
-		 *		ft_encoding_adobe_custom
-		 *		ft_encoding_apple_roman
 		 *
 		 * @param encoding		the Freetype encoding symbol. See above.
 		 * @return				<code>true</code> if charmap was valid
@@ -93,7 +80,6 @@ class	FTFace
 		 * Gets the kerning vector between two glyphs
 		 */
 		FT_Vector& KernAdvance( unsigned int index1, unsigned int index2);
-		
 
 		/**
 		 * Loads and creates a Freetype glyph.
@@ -104,7 +90,6 @@ class	FTFace
 		 * Gets the current Freetype face.
 		 */
 		FT_Face* Face() const { return ftFace;}
-		
 
 		/**
 		 * Queries for errors.
@@ -113,17 +98,16 @@ class	FTFace
 		 */
 		FT_Error Error() const { return err; }
 		
-		// attributes
-		
 	private:
-		// methods
-		
-		// attributes
-
 		/**
 		 * The size object associated with this face
 		 */
 		FTSize	charSize;
+		
+		/**
+		 * The Character Map object associated with this face
+		 */
+		FTCharmap* charMap;
 
 		/**
 		 * The Freetype face
diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index 827f552..20d2014 100755
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -1,11 +1,13 @@
 #include	"FTFace.h"
 #include	"FTLibrary.h"
+#include	"FTCharmap.h"
 #include	"FTGL.h"
 
 
 FTFace::FTFace()
 :	ftFace(0),
 	numCharMaps(0),
+	charMap(0),
 	numGlyphs(0),
 	err(0)
 {}
@@ -13,6 +15,7 @@ FTFace::FTFace()
 
 FTFace::~FTFace()
 {
+	delete charMap;
 	Close();
 }
 
@@ -30,6 +33,7 @@ bool FTFace::Open( const char* filename)
     }
     else
     {
+		charMap = new FTCharmap( *ftFace);
 		return true;
 	}
 }
@@ -40,13 +44,13 @@ void FTFace::Close()
 	if( ftFace)
 	{
 		FT_Done_Face( *ftFace);
-		delete ftFace; // is this a prob?
+		delete ftFace;
 		ftFace = 0;
 	}
 }
 
 
-FTSize& FTFace::Size( const unsigned int size, const unsigned int res )
+FTSize& FTFace::Size( const unsigned int size, const unsigned int res)
 {
 	if( !charSize.CharSize( ftFace, size, res, res))
 	{
@@ -57,43 +61,19 @@ FTSize& FTFace::Size( const unsigned int size, const unsigned int res )
 }
 
 
-bool FTFace::CharMap( FT_Encoding encoding )
+bool FTFace::CharMap( FT_Encoding encoding)
 {
-	
-// 	FT_CharMap  found = 0;
-//     FT_CharMap  charmap;
-//     int         n;
-// 
-//     for ( n = 0; n < face->num_charmaps; n++ )
-//     {
-//       charmap = face->charmaps[n];
-//       if ( charmap->platform_id == my_platform_id &&
-//            charmap->encoding_id == my_encoding_id )
-//       {
-//         found = charmap;
-//         break;
-//       }
-//     }
-// 
-//     if ( !found ) { ... }
-// 
-//     /* now, select the charmap for the face object */
-//     error = FT_Set_CharMap( face, found );
-//    if ( error ) { ... }
-
-
-	err = FT_Select_Charmap( *ftFace, encoding );
-	return !err;
+	return charMap->CharMap( encoding);
 }
 
 
-unsigned int FTFace::CharIndex( unsigned int index ) const
+unsigned int FTFace::CharIndex( unsigned int index) const
 {
-	return FT_Get_Char_Index( *ftFace, index);
+	return charMap->CharIndex( index);
 }
 
 
-FT_Vector& FTFace::KernAdvance( unsigned int index1, unsigned int index2 )
+FT_Vector& FTFace::KernAdvance( unsigned int index1, unsigned int index2)
 {
 	kernAdvance.x = 0; kernAdvance.y = 0;