Edit

kc3-lang/ftgl/src/FTCharmap.cpp

Branch :

  • Show log

    Commit

  • Author : sammy
    Date : 2008-04-04 12:43:38
    Hash : 7c358859
    Message : * Generate a config.h file instead of passing all defines in the compiler command line. * "make install" now properly installs the includes, the documentation and the .pc file. * Generate a shared library.

  • src/FTCharmap.cpp
  • #include "config.h"
    
    #include "FTFace.h"
    #include "FTCharmap.h"
    
    
    FTCharmap::FTCharmap( FTFace* face)
    :   ftFace( *(face->Face())),
        err(0)
    {
        if( !ftFace->charmap)
        {
            err = FT_Set_Charmap( ftFace, ftFace->charmaps[0]);
        }
        
        ftEncoding = ftFace->charmap->encoding;
    }
    
    
    FTCharmap::~FTCharmap()
    {
        charMap.clear();
    }
    
    
    bool FTCharmap::CharMap( FT_Encoding encoding)
    {
        if( ftEncoding == encoding)
        {
            err = 0;
            return true;
        }
        
        err = FT_Select_Charmap( ftFace, encoding );
        
        if( !err)
        {
            ftEncoding = encoding;
            charMap.clear();
        }
            
        return !err;
    }
    
    
    unsigned int FTCharmap::GlyphListIndex( unsigned int characterCode )
    {
        return charMap.find( characterCode);
    }
    
    
    unsigned int FTCharmap::FontIndex( unsigned int characterCode )
    {
        return FT_Get_Char_Index( ftFace, characterCode);
    }
    
    
    void FTCharmap::InsertIndex( const unsigned int characterCode, const unsigned int containerIndex)
    {
        charMap.insert( characterCode, containerIndex);
    }