FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
truetypefont.h
Go to the documentation of this file.
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_TRUETYPEFONT_H
23 #define FIFE_FONTS_TRUETYPEFONT_H
24 
25 // Standard C++ library includes
26 #include <map>
27 #include <string>
28 
29 // 3rd party library includes
30 #include <SDL_ttf.h>
31 
32 // FIFE includes
33 // These includes are split up in two parts, separated by one empty line
34 // First block: files included from the FIFE root src directory
35 // Second block: files included from the same folder
36 #include "fontbase.h"
37 
38 namespace FIFE {
39 
51  class TrueTypeFont: public FontBase {
52  public:
53 
60  TrueTypeFont(const std::string& filename, int32_t size);
61 
65  virtual ~TrueTypeFont();
66 
67  // Inherited from Font
68 
69  virtual int32_t getWidth(const std::string& text) const;
70 
71  virtual int32_t getHeight() const;
72 
73  virtual void setBoldStyle(bool style);
74  virtual void setItalicStyle(bool style);
75  virtual void setUnderlineStyle(bool style);
76  virtual void setStrikethroughStyle(bool style);
77  virtual int32_t getFontStyleMask() const;
78 
79  virtual SDL_Surface *renderString(const std::string& text);
80 
81  virtual void setColor(uint8_t r,uint8_t g,uint8_t b, uint8_t a = 255);
82 
83  protected:
84  TTF_Font* mFont;
85 
86  int32_t mFontStyle;
87  };
88 }
89 
90 #endif //
virtual void setItalicStyle(bool style)
Sets the use of italic style.
virtual SDL_Surface * renderString(const std::string &text)
virtual void setStrikethroughStyle(bool style)
Sets the use of strikethrough style.
virtual int32_t getHeight() const
gets height of this font
virtual int32_t getWidth(const std::string &text) const
gets width of given text
virtual int32_t getFontStyleMask() const
TrueTypeFont(const std::string &filename, int32_t size)
Constructor.
Abstract Font Base Class Uses a pool for rendered strings.
Definition: fontbase.h:48
unsigned char uint8_t
Definition: core.h:38
virtual ~TrueTypeFont()
Destructor.
virtual void setBoldStyle(bool style)
Sets the use of bold style.
virtual void setUnderlineStyle(bool style)
Sets the use of underline style.
SDL True Type Font implementation of Font.
Definition: truetypefont.h:51
TTF_Font * mFont
Definition: truetypefont.h:84
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.