00001 #include "FTFace.h" 00002 #include "FTCharmap.h" 00003 00004 00005 FTCharmap::FTCharmap( FTFace* face) 00006 : ftFace( *(face->Face())), 00007 err(0) 00008 { 00009 if( !ftFace->charmap) 00010 { 00011 err = FT_Set_Charmap( ftFace, ftFace->charmaps[0]); 00012 } 00013 00014 ftEncoding = ftFace->charmap->encoding; 00015 } 00016 00017 00018 FTCharmap::~FTCharmap() 00019 { 00020 charMap.clear(); 00021 } 00022 00023 00024 bool FTCharmap::CharMap( FT_Encoding encoding) 00025 { 00026 if( ftEncoding == encoding) 00027 { 00028 return true; 00029 } 00030 00031 err = FT_Select_Charmap( ftFace, encoding ); 00032 00033 if( !err) 00034 { 00035 ftEncoding = encoding; 00036 } 00037 else 00038 { 00039 ftEncoding = ft_encoding_none; 00040 } 00041 00042 charMap.clear(); 00043 return !err; 00044 } 00045 00046 00047 unsigned int FTCharmap::GlyphListIndex( unsigned int characterCode ) 00048 { 00049 return charMap.find( characterCode); 00050 } 00051 00052 00053 unsigned int FTCharmap::FontIndex( unsigned int characterCode ) 00054 { 00055 return FT_Get_Char_Index( ftFace, characterCode); 00056 } 00057 00058 00059 void FTCharmap::InsertIndex( const unsigned int characterCode, const unsigned int containerIndex) 00060 { 00061 charMap.insert( characterCode, containerIndex); 00062 }