00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FONT_H
00023 #define FONT_H
00024
00025 #include <iostream>
00026 #include <SDL/SDL.h>
00027 #include <SDL/SDL_ttf.h>
00028 #include <map>
00029
00030 #include "case.h"
00031
00033 namespace Fonts {
00034
00036 const int SIZE_LINE_BREAK=17;
00037
00039 const int SIZE_CHAR_SPACE=2;
00040
00042 const int SIZE_WHITESPACE=10-SIZE_CHAR_SPACE;
00043
00045 static const int FONT_BUTTON_TEXT=16;
00046
00048 static const int FONT_STANDARD=13;
00049
00051 static const int FONT_INFO_PAGE=11;
00052
00054 extern const Color COLOR_BLACK;
00055
00057 extern const Color COLOR_WHITE;
00058
00060 extern const Color COLOR_BLUE;
00061
00063 extern const Color COLOR_ORANGE;
00064
00066 extern const Color COLOR_GREEN;
00067
00069 extern const Color COLOR_YELLOW;
00070
00072 enum Quality { QUALITY_SOLID=0, QUALITY_BLEND };
00073
00074
00075 typedef TTF_Font Font;
00076 extern std::map<int, Font*> g_Fonts;
00077
00083 bool loadFont(const ustring &path, int size);
00084
00092 SDL_Surface* renderGlyph(Uint16 ch, int size, const Color &color, const Quality &quality);
00093
00103 int glyphBase(int y, Uint16 ch, int size);
00104
00112 bool discardChar(Uint16 ch);
00113
00121 bool lineWillBreak(const Point &p, int rightClamp, const ustring &str, int size);
00122
00130 int drawString(const Point &p, const ustring &str, int size, const Color &color);
00131
00141 int drawString(const Point &p, int delimiter, int rightClamp, const ustring &str, int size, const Color &color);
00142
00151 int drawStringMulticolor(const Point &p, int delimiter, int rightClamp, const ustring &str, int size, const ColorRangeVector &vec);
00152
00161 int drawStringCentered(int y, int delimiter, const ustring &str, int size, const Color &color);
00162
00169 void drawStringBlended(const Point &p, const ustring &str, int size, const Color &color);
00170
00176 int getWidth(const ustring &str, int size);
00177
00183 int getGlyphWidth(Uint16 ch, int size);
00184
00189 int getHeight(int size);
00190
00195 Font* queryFont(int size);
00196
00201 void pushFont(int size, Font *font);
00202
00204 void clearFontStack();
00205
00206 };
00207
00208 #endif