f2400eea0f6a33a542a6941f0bc44cefa7cef8a2
[blender.git] / extern / bFTGL / src / FTCharmap.cpp
1 #include "FTFace.h"
2 #include "FTCharmap.h"
3
4
5 FTCharmap::FTCharmap( FTFace* face)
6 :   ftFace( *(face->Face())),
7     err(0)
8 {
9     if( !ftFace->charmap)
10     {
11         err = FT_Set_Charmap( ftFace, ftFace->charmaps[0]);
12     }
13     
14     ftEncoding = ftFace->charmap->encoding;
15 }
16
17
18 FTCharmap::~FTCharmap()
19 {
20     charMap.clear();
21 }
22
23
24 bool FTCharmap::CharMap( FT_Encoding encoding)
25 {
26     if( ftEncoding == encoding)
27     {
28         return true;
29     }
30     
31     err = FT_Select_Charmap( ftFace, encoding );
32     
33     if( !err)
34     {
35         ftEncoding = encoding;
36     }
37     else
38     {
39         ftEncoding = ft_encoding_none;
40     }
41         
42     charMap.clear();
43     return !err;
44 }
45
46
47 unsigned int FTCharmap::GlyphListIndex( unsigned int characterCode )
48 {
49     return charMap.find( characterCode);
50 }
51
52
53 unsigned int FTCharmap::FontIndex( unsigned int characterCode )
54 {
55     return FT_Get_Char_Index( ftFace, characterCode);
56 }
57
58
59 void FTCharmap::InsertIndex( const unsigned int characterCode, const unsigned int containerIndex)
60 {
61     charMap.insert( characterCode, containerIndex);
62 }