|
FifeGUI 0.2.0
A C++ GUI library designed for games.
|
#include <truetypefont.hpp>
Public Member Functions | |
| void | drawString (fcn::Graphics *graphics, std::string const &text, int x, int y) override |
| virtual int | getGlyphSpacing () |
| int | getHeight () const override |
| virtual int | getRowSpacing () |
| int | getWidth (std::string const &text) const override |
| virtual bool | isAntiAlias () |
| TrueTypeFont & | operator= (TrueTypeFont &&)=delete |
| TrueTypeFont & | operator= (TrueTypeFont const &)=delete |
| virtual void | setAntiAlias (bool antiAlias) |
| virtual void | setGlyphSpacing (int spacing) |
| virtual void | setRowSpacing (int spacing) |
| TrueTypeFont (std::string const &filename, int size) | |
| TrueTypeFont (TrueTypeFont &&)=delete | |
| TrueTypeFont (TrueTypeFont const &)=delete | |
| Public Member Functions inherited from fcn::Font | |
| Font (Font &&)=default | |
| Font (Font const &)=default | |
| virtual int | getStringIndexAt (std::string const &text, int x) const |
| Font & | operator= (Font &&)=default |
| Font & | operator= (Font const &)=default |
Protected Attributes | |
| bool | mAntiAlias |
| std::string | mFilename |
| TTF_Font * | mFont |
| int | mGlyphSpacing |
| int | mHeight {} |
| int | mRowSpacing |
SDL2/FreeType implementation for rendering TrueType fonts.
It uses the SDL_ttf library to display True Type Fonts with SDL.
Note: initialize the SDL_ttf library (TTF_Init) before using this class and call TTF_Quit when finished.
Definition at line 29 of file truetypefont.hpp.
| fcn::sdl2::TrueTypeFont::TrueTypeFont | ( | std::string const & | filename, |
| int | size ) |
Constructor.
| filename | the filename of the True Type Font. |
| size | the size the font should be in. |
Definition at line 18 of file truetypefont.cpp.
References mAntiAlias, mFilename, mFont, mGlyphSpacing, and mRowSpacing.
|
override |
Definition at line 31 of file truetypefont.cpp.
|
overridevirtual |
Draws a string.
NOTE: You normally won't use this function to draw text since Graphics contains better functions for drawing text.
| Graphics & Rendering | A Graphics object to use for drawing. |
| text | The string to draw. |
| x | The x coordinate where to draw the string. |
| y | The y coordinate where to draw the string. |
Implements fcn::Font.
Definition at line 50 of file truetypefont.cpp.
References fcn::Color::a, fcn::Color::b, fcn::Color::g, fcn::Graphics::getColor(), getRowSpacing(), mAntiAlias, mFont, and fcn::Color::r.
|
virtual |
Gets the spacing between letters in pixels.
Definition at line 128 of file truetypefont.cpp.
References mGlyphSpacing.
|
overridevirtual |
Gets the height of the glyphs in the font.
Implements fcn::Font.
Definition at line 45 of file truetypefont.cpp.
References mFont, and mRowSpacing.
|
virtual |
Gets the spacing between rows in pixels.
Definition at line 118 of file truetypefont.cpp.
References mRowSpacing.
Referenced by drawString().
|
overridevirtual |
Gets the width of a string.
The width of a string is not necessarily the sum of all the widths of it's glyphs.
| text | The string to return the width of. |
Implements fcn::Font.
Definition at line 36 of file truetypefont.cpp.
References mFont.
|
virtual |
Checks if anti aliasing is used.
Definition at line 138 of file truetypefont.cpp.
References mAntiAlias.
|
virtual |
Enable or disable anti-aliasing for rendered glyphs.
| antiAlias | True to enable anti-aliasing, false to disable. |
Definition at line 133 of file truetypefont.cpp.
References mAntiAlias.
|
virtual |
Sets the spacing between letters in pixels.
Default is 0 pixels. The spacing can be negative.
| spacing | the spacing in pixels. |
Definition at line 123 of file truetypefont.cpp.
References mGlyphSpacing.
|
virtual |
Sets the spacing between rows in pixels.
Default is 0 pixels. The spacing can be negative.
| spacing | the spacing in pixels. |
Definition at line 113 of file truetypefont.cpp.
References mRowSpacing.
|
protected |
Whether anti-aliasing is enabled for rendering.
Definition at line 116 of file truetypefont.hpp.
Referenced by drawString(), isAntiAlias(), setAntiAlias(), and TrueTypeFont().
|
protected |
Filename of the font used to create mFont.
Definition at line 113 of file truetypefont.hpp.
Referenced by TrueTypeFont().
|
protected |
Underlying TTF_Font pointer from SDL_ttf.
Definition at line 101 of file truetypefont.hpp.
Referenced by drawString(), getHeight(), getWidth(), and TrueTypeFont().
|
protected |
Additional spacing between glyphs in pixels.
Definition at line 107 of file truetypefont.hpp.
Referenced by getGlyphSpacing(), setGlyphSpacing(), and TrueTypeFont().
|
protected |
Cached font height in pixels.
Definition at line 104 of file truetypefont.hpp.
|
protected |
Additional spacing between rows in pixels.
Definition at line 110 of file truetypefont.hpp.
Referenced by getHeight(), getRowSpacing(), setRowSpacing(), and TrueTypeFont().