FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
imagefontbase.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_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 
46  class ImageFontBase: public FontBase {
47  public:
48 
52  ImageFontBase();
53 
57  virtual ~ImageFontBase();
58 
62  virtual int32_t getWidth(const std::string& text) const;
63 
66  virtual int32_t getHeight() const;
67 
68  virtual SDL_Surface *renderString(const std::string& text);
69  virtual void setColor(uint8_t r,uint8_t g,uint8_t b, uint8_t a = 255);
70 
71  protected:
72  // A glyph (visible character)
73  typedef struct {
74  // The offset of the glyph relative to the top-left corner.
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<int32_t,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 '?'
87 
88  int32_t m_height;
89  };
90 }
91 
92 #endif // end GCN_SDLTRUETYPEFONT_HPP
type_glyphs m_glyphs
Definition: imagefontbase.h:82
virtual int32_t getWidth(const std::string &text) const
Get the width in pixels a given text would occupy.
virtual void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Set the color the text should be rendered in.
virtual ~ImageFontBase()
Destructor.
Abstract Font Base Class Uses a pool for rendered strings.
Definition: fontbase.h:48
std::map< int32_t, s_glyph > type_glyphs
Definition: imagefontbase.h:81
unsigned char uint8_t
Definition: core.h:38
virtual SDL_Surface * renderString(const std::string &text)
virtual int32_t getHeight() const
Get the height in pixels a text line would occupy.
ImageFontBase()
Constructor.
ImageFont base class.
Definition: imagefontbase.h:46