Mercurial > fife-parpg
comparison engine/core/video/fonts/imagefontbase.h @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 #ifndef FIFE_FONTS_IMAGEFONTBASE_H | |
23 #define FIFE_FONTS_IMAGEFONTBASE_H | |
24 | |
25 // Standard C++ library includes | |
26 #include <map> | |
27 #include <string> | |
28 | |
29 // 3rd party library includes | |
30 | |
31 // FIFE includes | |
32 // These includes are split up in two parts, separated by one empty line | |
33 // First block: files included from the FIFE root src directory | |
34 // Second block: files included from the same folder | |
35 #include "util/structures/point.h" | |
36 | |
37 #include "fontbase.h" | |
38 | |
39 namespace FIFE { | |
40 | |
41 /** ImageFont base class | |
42 * | |
43 * Just set the glyphs/placeholder in any derived class and the rendering | |
44 * is handled by this class. Also frees all glyph surfaces on destruction. | |
45 */ | |
46 class ImageFontBase: public FontBase { | |
47 public: | |
48 | |
49 /** | |
50 * Constructor. | |
51 */ | |
52 ImageFontBase(); | |
53 | |
54 /** | |
55 * Destructor. | |
56 */ | |
57 virtual ~ImageFontBase(); | |
58 | |
59 /** Get the width in pixels a given text would occupy | |
60 * @param text The text that should be measured. | |
61 */ | |
62 virtual int getWidth(const std::string& text) const; | |
63 | |
64 /** Get the height in pixels a text line would occupy | |
65 */ | |
66 virtual int getHeight() const; | |
67 | |
68 virtual SDL_Surface *renderString(const std::string& text); | |
69 virtual void setColor(Uint8 r, Uint8 g, Uint8 b); | |
70 | |
71 protected: | |
72 // A glyph (visible character) | |
73 typedef struct { | |
74 // The offset of the glyph relative to the top-left corner. | |
75 Point offset; | |
76 // The glyphs image | |
77 // should be with SDL_SRCALPHA off, so that it's just copied over. | |
78 SDL_Surface* surface; | |
79 } s_glyph; | |
80 | |
81 typedef std::map<int,s_glyph> type_glyphs; | |
82 type_glyphs m_glyphs; | |
83 | |
84 // The glyph used, when the real glyph is not found | |
85 // Should default to '?' | |
86 s_glyph m_placeholder; | |
87 | |
88 int mHeight; | |
89 int mGlyphSpacing; | |
90 int mRowSpacing; | |
91 | |
92 std::string mFilename; | |
93 bool mAntiAlias; | |
94 }; | |
95 } | |
96 | |
97 #endif // end GCN_SDLTRUETYPEFONT_HPP |