FTGlyphContainer.h

Go to the documentation of this file.
00001 #ifndef     __FTGlyphContainer__
00002 #define     __FTGlyphContainer__
00003 
00004 #include <ft2build.h>
00005 #include FT_FREETYPE_H
00006 #include FT_GLYPH_H
00007 
00008 #include "FTGL.h"
00009 #include "FTBBox.h"
00010 #include "FTPoint.h"
00011 #include "FTVector.h"
00012 
00013 class FTFace;
00014 class FTGlyph;
00015 class FTCharmap;
00016 
00017 /**
00018  * FTGlyphContainer holds the post processed FTGlyph objects.
00019  *
00020  * @see FTGlyph
00021  */
00022 class FTGL_EXPORT FTGlyphContainer
00023 {
00024         typedef FTVector<FTGlyph*> GlyphVector;
00025     public:
00026         /**
00027          * Constructor
00028          *
00029          * @param face      The Freetype face
00030          */
00031         FTGlyphContainer( FTFace* face);
00032 
00033         /**
00034          * Destructor
00035          */
00036         ~FTGlyphContainer();
00037 
00038         /**
00039          * Sets the character map for the face.
00040          *
00041          * @param encoding      the Freetype encoding symbol. See above.
00042          * @return              <code>true</code> if charmap was valid
00043          *                      and set correctly
00044          */
00045         bool CharMap( FT_Encoding encoding);
00046 
00047         /**
00048          * Get the font index of the input character.
00049          *
00050          * @param characterCode The character code of the requested glyph in the
00051          *                      current encoding eg apple roman.
00052          * @return      The font index for the character.
00053          */
00054         unsigned int FontIndex( const unsigned int characterCode ) const;
00055         
00056         /**
00057          * Adds a glyph to this glyph list.
00058          *
00059          * @param glyph         The FTGlyph to be inserted into the container
00060          * @param characterCode The char code of the glyph NOT the glyph index.
00061          */
00062         void Add( FTGlyph* glyph, const unsigned int characterCode);
00063 
00064         /**
00065          * Get a glyph from the glyph list
00066          *
00067          * @param characterCode The char code of the glyph NOT the glyph index      
00068          * @return              An FTGlyph or <code>null</code> is it hasn't been
00069          * loaded.
00070          */
00071         FTGlyph* Glyph( const unsigned int characterCode) const;
00072 
00073         /**
00074          * Get the bounding box for a character.
00075          * @param characterCode The char code of the glyph NOT the glyph index      
00076          */
00077         FTBBox BBox( const unsigned int characterCode) const;
00078         
00079         /**
00080         * Returns the kerned advance width for a glyph.
00081         *
00082         * @param characterCode     glyph index of the character
00083         * @param nextCharacterCode the next glyph in a string
00084         * @return                  advance width
00085         */
00086         float Advance( const unsigned int characterCode, const unsigned int nextCharacterCode);
00087         
00088         /**
00089          * Renders a character
00090          * @param characterCode      the glyph to be Rendered
00091          * @param nextCharacterCode  the next glyph in the string. Used for kerning.
00092          * @param penPosition        the position to Render the glyph
00093          * @return                   The distance to advance the pen position after Rendering
00094          */
00095         FTPoint Render( const unsigned int characterCode, const unsigned int nextCharacterCode, FTPoint penPosition);
00096         
00097         /**
00098          * Queries the Font for errors.
00099          *
00100          * @return  The current error code.
00101          */
00102         FT_Error Error() const { return err;}
00103 
00104     private:
00105         /**
00106          * The FTGL face
00107          */
00108         FTFace* face;
00109 
00110         /**
00111          * The Character Map object associated with the current face
00112          */
00113         FTCharmap* charMap;
00114 
00115         /**
00116          * A structure to hold the glyphs
00117          */
00118         GlyphVector glyphs;
00119 
00120         /**
00121          * Current error code. Zero means no error.
00122          */
00123         FT_Error err;
00124 };
00125 
00126 
00127 #endif  //  __FTGlyphContainer__

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