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 00093 virtual bool FaceSize( const unsigned int size, const unsigned int res = 72); 00094 00100 unsigned int FaceSize() const; 00101 00108 virtual void Depth( float d){} 00109 00115 float Ascender() const; 00116 00122 float Descender() const; 00123 00135 void BBox( const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz); 00136 00148 void BBox( const wchar_t* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz); 00149 00156 float Advance( const wchar_t* string); 00157 00164 float Advance( const char* string); 00165 00171 virtual void Render( const char* string ); 00172 00178 virtual void Render( const wchar_t* string ); 00179 00185 FT_Error Error() const { return err;} 00186 00187 protected: 00197 virtual FTGlyph* MakeGlyph( unsigned int g) = 0; 00198 00202 FTFace face; 00203 00207 FTSize charSize; 00208 00212 FT_Error err; 00213 00214 private: 00222 inline void DoRender( const unsigned int chr, const unsigned int nextChr); 00223 00229 inline void CheckGlyph( const unsigned int chr); 00230 00234 FTGlyphContainer* glyphList; 00235 00239 FTPoint pen; 00240 }; 00241 00242 00243 #endif // __FTFont__ 00244