00001 /* MANTAINER: Bernard */ 00002 00003 #ifndef FONT_TTF_H 00004 #define FONT_TTF_H 00005 00006 #include <string> 00007 #include "SDL.h" 00008 #include "SDL_ttf.h" 00009 00010 #include "texturemanager.h" 00011 #include "hash_hack.h" 00012 #include "stlextdefs.h" 00013 00014 #include "font.h" 00015 00024 class FontTTF : public Font 00025 { 00026 public: 00027 00028 // TODO: Somenoe should call TTF_Quit 00029 FontTTF(const char* file, int ptsize); 00030 virtual ~FontTTF(); 00031 00032 virtual void RenderUTF8(const std::string &utf8str, float x, float y); 00033 00034 virtual int Ascent(); 00035 00042 virtual void cleanCache(); 00043 00044 virtual int getWwidth(); 00045 00052 virtual int getTextWidth(const std::string &utf8str); 00053 private: 00054 TTF_Font *mFont; 00055 00056 typedef struct SCacheMember 00057 { 00058 // TextureRef texture; // unsued 00059 int usages; // number of usages in last few seconds 00060 int w; // width of text 00061 int h; // height of text 00062 SDL_Surface *surface; // surface with rendered font 00063 00064 } SCacheMember; 00065 00066 typedef STL_EXT_NS::hash_map<std::string, SCacheMember*> TStringHash; 00067 00068 TStringHash mRenderedCache; 00069 00070 int mWwidth; 00071 }; 00072 00073 #endif
1.4.5