FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
fontbase.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 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 
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:
85 
86  SDL_Color mColor;
87  int32_t mGlyphSpacing;
88  int32_t mRowSpacing;
89 
90  std::string mFilename;
96  bool m_coloring;
97  };
98 
99 }
100 
101 #endif
virtual void setUnderlineStyle(bool style)
Sets the use of underline style.
Definition: fontbase.cpp:101
void invalidate()
Definition: fontbase.cpp:57
int32_t getGlyphSpacing() const
Gets the spacing between letters in pixels.
Definition: fontbase.cpp:73
virtual bool isUnderlineStyle() const
Checks if underline style is used.
Definition: fontbase.cpp:105
virtual bool isBoldStyle() const
Checks if bold style is used.
Definition: fontbase.cpp:89
Base Class for Images.
Definition: image.h:48
int32_t mGlyphSpacing
Definition: fontbase.h:87
Generic pool for rendered text Caches a number of Images with text, as rendered by a Font...
virtual ~FontBase()
Definition: fontbase.h:51
bool m_coloring
Definition: fontbase.h:96
Image * getAsImageMultiline(const std::string &text)
Gets given text as Image.
Definition: fontbase.cpp:167
virtual void setAntiAlias(bool antiAlias)
Sets the use of anti aliasing.
Definition: fontbase.cpp:77
virtual void setStrikethroughStyle(bool style)
Sets the use of strikethrough style.
Definition: fontbase.cpp:109
SDL_Color mColor
Definition: fontbase.h:86
bool m_italicStyle
Definition: fontbase.h:93
Abstract Font Base Class Uses a pool for rendered strings.
Definition: fontbase.h:48
virtual void setDynamicColoring(bool coloring)
Definition: fontbase.cpp:117
TextRenderPool m_pool
Definition: fontbase.h:84
virtual int32_t getStringIndexAt(const std::string &text, int32_t x) const
Definition: fontbase.cpp:129
void setRowSpacing(int32_t spacing)
Sets the spacing between rows in pixels.
Definition: fontbase.cpp:61
virtual void setItalicStyle(bool style)
Sets the use of italic style.
Definition: fontbase.cpp:93
int32_t mRowSpacing
Definition: fontbase.h:88
virtual void setBoldStyle(bool style)
Sets the use of bold style.
Definition: fontbase.cpp:85
virtual bool isStrikethroughStyle() const
Checks if strikethrough style is used.
Definition: fontbase.cpp:113
int32_t getRowSpacing() const
Gets the spacing between rows in pixels.
Definition: fontbase.cpp:65
bool m_strikeStyle
Definition: fontbase.h:95
Image * getAsImage(const std::string &text)
Gets given text as Image The rsulting image is pooled, so it&#39;s not that time critical.
Definition: fontbase.cpp:157
virtual bool isItalicStyle() const
Checks if italic style is used.
Definition: fontbase.cpp:97
void setGlyphSpacing(int32_t spacing)
Sets the spacing between letters in pixels.
Definition: fontbase.cpp:69
bool m_antiAlias
Definition: fontbase.h:91
bool m_underlineStyle
Definition: fontbase.h:94
std::string mFilename
Definition: fontbase.h:90
Pure abstract Font interface.
Definition: ifont.h:43
std::string splitTextToWidth(const std::string &text, int32_t render_width)
Definition: fontbase.cpp:221
virtual bool isDynamicColoring() const
Definition: fontbase.cpp:121
virtual SDL_Surface * renderString(const std::string &text)=0
SDL_Color getColor() const
Get the color the text was rendered in.
Definition: fontbase.cpp:125
virtual bool isAntiAlias() const
Checks if anti aliasing is used.
Definition: fontbase.cpp:81
bool m_boldStyle
Definition: fontbase.h:92