FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
fontbase.h
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 *
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  void setAntiAlias(bool antiAlias);
59  bool isAntiAlias();
60  virtual int32_t getStringIndexAt(const std::string &text, int32_t x) const;
61 
62  Image* getAsImage(const std::string& text);
63  Image* getAsImageMultiline(const std::string& text);
64  std::string splitTextToWidth (const std::string& text, int32_t render_width);
65 
66  SDL_Color getColor() const;
67 
68  virtual SDL_Surface* renderString(const std::string& text) = 0;
69 
70  protected:
71  TextRenderPool m_pool;
72 
73  SDL_Color mColor;
74  int32_t mGlyphSpacing;
75  int32_t mRowSpacing;
76 
77  std::string mFilename;
78  bool m_antiAlias;
79  };
80 
81 }
82 
83 #endif