Back to index

extremetuxracer  0.5beta
font.h
Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
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 _PP_FONT_H_
00020 #define _PP_FONT_H_
00021 
00022 #include <map>
00023 #include <string>
00024 
00025 #include "FT/FTFont.h"
00026 #include "alg/color.h"
00027 #include "alg/vec2d.h"
00028 
00029 namespace pp{
00030        
00031 class Font
00032 {
00033 private:
00034        FTFont *mp_font;
00035        pp::Color m_color;
00036 
00037 public:       
00038        Font(const char *fileName, unsigned int size, const pp::Color &color);
00039     Font(const char *fileName, unsigned int size, const pp::Color &color, bool isOutline);
00040 
00041 
00042        Font(FTFont *font, const pp::Color &color);
00043 
00044        ~Font();
00045 
00047        void draw(const char *string, float x, float y);
00048 
00050        void draw(const char *string, pp::Vec2d position);
00051 
00053        void draw(const wchar_t *string, float x, float y);
00054 
00056        void draw(const wchar_t *string, pp::Vec2d position);
00057 
00058        float ascender();
00059        float descender();
00060        float advance(const char* string);
00061        float advance(const wchar_t* string);
00062 
00063        pp::Color& getColor();
00064     void setColor(pp::Color& c);
00065 
00066        FTFont* getFTFont();
00067        
00068 //static stuff       
00069 private:
00070        
00072        static std::map<std::string, pp::Font*> sm_bindings;
00073 
00074 public:
00075        
00077        static bool registerFont(const char *binding, const char *fileName, unsigned int size, const pp::Color &color);
00078     static bool registerFont(const char *binding, const char *fileName, unsigned int size, const pp::Color &color, bool isOutline);
00079        
00081        static bool bindFont(const char *binding, const char *fontName);
00082        
00084        static bool bindFont(const char *binding, const char *fontName, const pp::Color& color);
00085 
00087        static Font* get(const char *binding);
00088        
00089        static void draw(const char *binding, const char *string, float x, float y);
00090 
00092        static wchar_t* utf8ToUnicode(const char* string);
00093 
00095        static void utf8ToUnicode(wchar_t* buff, const char* string);
00096 };
00097 
00098 } //namepsace pp
00099 
00100 #endif // _PP_FONT_H_