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
00047 FTFont( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
00048
00052 virtual ~FTFont();
00053
00063 bool Attach( const char* filename);
00064
00075 bool Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
00076
00084 bool CharMap( FT_Encoding encoding );
00085
00091 unsigned int CharMapCount();
00092
00098 FT_Encoding* CharMapList();
00099
00107 virtual bool FaceSize( const unsigned int size, const unsigned int res = 72);
00108
00114 unsigned int FaceSize() const;
00115
00122 virtual void Depth( float d){}
00123
00129 float Ascender() const;
00130
00136 float Descender() const;
00137
00149 void BBox( const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz);
00150
00162 void BBox( const wchar_t* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz);
00163
00170 float Advance( const wchar_t* string);
00171
00178 float Advance( const char* string);
00179
00185 virtual void Render( const char* string );
00186
00192 virtual void Render( const wchar_t* string );
00193
00199 FT_Error Error() const { return err;}
00200
00201 protected:
00211 virtual FTGlyph* MakeGlyph( unsigned int g) = 0;
00212
00216 FTFace face;
00217
00221 FTSize charSize;
00222
00226 FT_Error err;
00227
00228 private:
00236 inline void DoRender( const unsigned int chr, const unsigned int nextChr);
00237
00243 inline void CheckGlyph( const unsigned int chr);
00244
00248 FTGlyphContainer* glyphList;
00249
00253 FTPoint pen;
00254 };
00255
00256
00257 #endif // __FTFont__
00258