font.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Mike Polan                                      *
00003  *   kanadakid@gmail.com                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 // font.h: the Font engine
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 // ttf fonts
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

Generated on Fri Feb 22 22:29:23 2008 for Phoenix Wright Case Player API by  doxygen 1.5.3