00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef FONTMANAGER_H
00020 #define FONTMANAGER_H
00021
00022 #include <vector>
00023 #include <map>
00024
00025 namespace Pentagram { class Font; }
00026
00027
00028
00029 typedef struct _TTF_Font TTF_Font;
00030 class IDataSource;
00031
00032 class TTFont;
00033
00034
00035 class FontManager
00036 {
00037 public:
00038 FontManager(bool ttf_antialiasing);
00039 ~FontManager();
00040
00041 static FontManager* get_instance() { return fontmanager; }
00042
00046 Pentagram::Font* getGameFont(unsigned int fontnum,
00047 bool allowOverride=false);
00048
00050 Pentagram::Font* getTTFont(unsigned int ttfnum);
00051
00059 bool addTTFOverride(unsigned int fontnum, std::string filename,
00060 int pointsize, uint32 rgb, int bordersize,
00061 bool SJIS=false);
00062
00067 bool addJPOverride(unsigned int fontnum, unsigned int jpfont, uint32 rgb);
00068
00070 bool loadTTFont(unsigned int ttfnum, std::string filename,
00071 int pointsize, uint32 rgb, int bordersize);
00072
00073
00074 void resetGameFonts();
00075 private:
00076
00077 struct TTFId {
00078 std::string filename;
00079 int pointsize;
00080 bool operator<(const TTFId& other) const {
00081 return (pointsize < other.pointsize ||
00082 (pointsize == other.pointsize &&
00083 filename < other.filename));
00084 }
00085 };
00086 std::map<TTFId, TTF_Font*> ttf_fonts;
00087 bool ttf_antialiasing;
00088
00091 TTF_Font* getTTF_Font(std::string filename, int pointsize);
00092
00094 void setOverride(unsigned int fontnum, Pentagram::Font* override);
00095
00096 std::vector<Pentagram::Font*> overrides;
00097
00098 std::vector<Pentagram::Font*> ttfonts;
00099
00100 static FontManager* fontmanager;
00101 };
00102
00103
00104 #endif