FontManager.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2004-2006 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 // This is TTF_Font struct from SDL_ttf
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         // Reset the game fonts
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

Generated on Fri Jul 27 22:27:15 2007 for pentagram by  doxygen 1.4.7