Debian Codegraph @

engine/core/video/fonts/fontbase.h

raw
1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the FIFE team *
3 * http://www.fifengine.net *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Lesser General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2.1 of the License, or (at your option) any later version. *
10 * *
11 * This library 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 GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef FIFE_FONTS_FONTBASE_H
23 #define FIFE_FONTS_FONTBASE_H
24
25 // Standard C++ library includes
26 #include <string>
27
28 // Platform specific includes
29 #include "util/base/fife_stdint.h"
30
31 // 3rd party library includes
32 #include <SDL.h>
33
34 // FIFE includes
35 // These includes are split up in two parts, separated by one empty line
36 // First block: files included from the FIFE root src directory
37 // Second block: files included from the same folder
38 #include "textrenderpool.h"
39 #include "ifont.h"
40
41 struct SDL_Surface;
42 namespace FIFE {
43
44 /** Abstract Font Base Class
45 * Uses a pool for rendered strings.
46 * @see TextRenderPool
47 */
48 class FontBase: public IFont {
49 public:
50 FontBase();
51 virtual ~FontBase() {};
52
53 void invalidate();
54 void setRowSpacing (int32_t spacing);
55 int32_t getRowSpacing() const;
56 void setGlyphSpacing(int32_t spacing);
57 int32_t getGlyphSpacing() const;
58
59 virtual void setAntiAlias(bool antiAlias);
60 virtual bool isAntiAlias() const;
61 virtual void setBoldStyle(bool style);
62 virtual bool isBoldStyle() const;
63 virtual void setItalicStyle(bool style);
64 virtual bool isItalicStyle() const;
65 virtual void setUnderlineStyle(bool style);
66 virtual bool isUnderlineStyle() const;
67 virtual void setStrikethroughStyle(bool style);
68 virtual bool isStrikethroughStyle() const;
69
70 virtual void setDynamicColoring(bool coloring);
71 virtual bool isDynamicColoring() const;
72
73 virtual int32_t getStringIndexAt(const std::string &text, int32_t x) const;
74
75 Image* getAsImage(const std::string& text);
76 Image* getAsImageMultiline(const std::string& text);
77 std::string splitTextToWidth (const std::string& text, int32_t render_width);
78
79 SDL_Color getColor() const;
80
81 virtual SDL_Surface* renderString(const std::string& text) = 0;
82
83 protected:
84 TextRenderPool m_pool;
85
86 SDL_Color mColor;
87 int32_t mGlyphSpacing;
88 int32_t mRowSpacing;
89
90 std::string mFilename;
91 bool m_antiAlias;
92 bool m_boldStyle;
93 bool m_italicStyle;
94 bool m_underlineStyle;
95 bool m_strikeStyle;
96 bool m_coloring;
97 };
98
99 }
100
101 #endif