FTCharmap.h

Go to the documentation of this file.
00001 #ifndef     __FTCharmap__
00002 #define     __FTCharmap__
00003 
00004 
00005 #include <ft2build.h>
00006 #include FT_FREETYPE_H
00007 #include FT_GLYPH_H
00008 
00009 #include "FTCharToGlyphIndexMap.h"
00010 
00011 #include "FTGL.h"
00012 
00013 
00014 /**
00015  * FTCharmap takes care of specifying the encoding for a font and mapping
00016  * character codes to glyph indices.
00017  *
00018  * It doesn't preprocess all indices, only on an as needed basis. This may
00019  * seem like a performance penalty but it is quicker than using the 'raw'
00020  * freetype calls and will save significant amounts of memory when dealing
00021  * with unicode encoding
00022  *
00023  * @see "Freetype 2 Documentation" 
00024  *
00025  */
00026 
00027 class FTFace;
00028 
00029 class FTGL_EXPORT FTCharmap
00030 {
00031     public:
00032         /**
00033          * Constructor
00034          */
00035         FTCharmap( FTFace* face);
00036 
00037         /**
00038          * Destructor
00039          */
00040         virtual ~FTCharmap();
00041 
00042         /**
00043          * Queries for the current character map code.
00044          *
00045          * @return  The current character map code.
00046          */
00047         FT_Encoding Encoding() const { return ftEncoding;}
00048         
00049         /**
00050          * Sets the character map for the face.
00051          * Valid encodings as at Freetype 2.0.4
00052          *      ft_encoding_none
00053          *      ft_encoding_symbol
00054          *      ft_encoding_unicode
00055          *      ft_encoding_latin_2
00056          *      ft_encoding_sjis
00057          *      ft_encoding_gb2312
00058          *      ft_encoding_big5
00059          *      ft_encoding_wansung
00060          *      ft_encoding_johab
00061          *      ft_encoding_adobe_standard
00062          *      ft_encoding_adobe_expert
00063          *      ft_encoding_adobe_custom
00064          *      ft_encoding_apple_roman
00065          *
00066          * @param encoding  the Freetype encoding symbol. See above.
00067          * @return          <code>true</code> if charmap was valid and set
00068          *                  correctly. If the requested encoding is
00069          *                  unavailable it will be set to ft_encoding_none.
00070          */
00071         bool CharMap( FT_Encoding encoding);
00072         
00073         /**
00074          * Get the FTGlyphContainer index of the input character.
00075          *
00076          * @param characterCode The character code of the requested glyph in
00077          *                      the current encoding eg apple roman.
00078          * @return      The FTGlyphContainer index for the character or zero
00079          *              if it wasn't found
00080          */
00081         unsigned int GlyphListIndex( const unsigned int characterCode);
00082 
00083         /**
00084          * Get the font glyph index of the input character.
00085          *
00086          * @param characterCode The character code of the requested glyph in
00087          *                      the current encoding eg apple roman.
00088          * @return      The glyph index for the character.
00089          */
00090         unsigned int FontIndex( const unsigned int characterCode);
00091 
00092         /**
00093          * Set the FTGlyphContainer index of the character code.
00094          *
00095          * @param characterCode  The character code of the requested glyph in
00096          *                       the current encoding eg apple roman.
00097          * @param containerIndex The index into the FTGlyphContainer of the
00098          *                       character code.
00099          */
00100         void InsertIndex( const unsigned int characterCode, const unsigned int containerIndex);
00101 
00102         /**
00103          * Queries for errors.
00104          *
00105          * @return  The current error code. Zero means no error.
00106          */
00107         FT_Error Error() const { return err;}
00108         
00109     private:
00110         /**
00111          * Current character map code.
00112          */
00113         FT_Encoding ftEncoding;
00114         
00115         /**
00116          * The current Freetype face.
00117          */
00118         const FT_Face ftFace;
00119         
00120         /**
00121          * A structure that maps glyph indices to character codes
00122          *
00123          * < character code, face glyph index>
00124          */
00125         typedef FTCharToGlyphIndexMap CharacterMap;
00126         CharacterMap charMap;
00127         
00128         /**
00129          * Current error code.
00130          */
00131         FT_Error err;
00132         
00133 };
00134 
00135 
00136 #endif  //  __FTCharmap__

Generated on Tue Jul 5 14:16:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1