00001 #ifndef __FTFont__
00002 #define __FTFont__
00003
00004 #include <ft2build.h>
00005 #include FT_FREETYPE_H
00006
00007 #include "FTFace.h"
00008 #include "FTGL.h"
00009
00010 class FTGlyphContainer;
00011 class FTGlyph;
00012
00013
00031 class FTGL_EXPORT FTFont
00032 {
00033 public:
00039 FTFont( const char* fontname);
00040
00049 FTFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
00050
00054 virtual ~FTFont();
00055
00065 bool Attach( const char* filename);
00066
00077 bool Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
00078
00086 bool CharMap( FT_Encoding encoding );
00087
00093 unsigned int CharMapCount();
00094
00100 FT_Encoding* CharMapList();
00101
00109 virtual bool FaceSize( const unsigned int size, const unsigned int res = 72);
00110
00116 unsigned int FaceSize() const;
00117
00124 virtual void Depth( float d){}
00125
00131 float Ascender() const;
00132
00138 float Descender() const;
00139
00151 void BBox( const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz);
00152
00164 void BBox( const wchar_t* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz);
00165
00172 float Advance( const wchar_t* string);
00173
00180 float Advance( const char* string);
00181
00187 virtual void Render( const char* string );
00188
00194 virtual void Render( const wchar_t* string );
00195
00201 FT_Error Error() const { return err;}
00202
00203 protected:
00213 virtual FTGlyph* MakeGlyph( unsigned int g) = 0;
00214
00218 FTFace face;
00219
00223 FTSize charSize;
00224
00228 FT_Error err;
00229
00230 private:
00238 inline void DoRender( const unsigned int chr, const unsigned int nextChr);
00239
00245 inline void CheckGlyph( const unsigned int chr);
00246
00250 FTGlyphContainer* glyphList;
00251
00255 FTPoint pen;
00256 };
00257
00258
00259 #endif // __FTFont__
00260