- nom
- TrueTypeFont
TrueType fonts renderer. More...
#include <TrueTypeFont.hpp>
Public Member Functions | |
| TrueTypeFont (void) | |
| Default constructor; we initialize the SDL_ttf extension here. | |
| ~TrueTypeFont (void) | |
| Default destructor; we shutdown the SDL_ttf extension here. | |
| IFont::SharedPtr | clone (void) const |
| Return a std::shared_ptr copy of this instance. | |
| bool | valid (void) const |
| Is this object initialized – not nullptr? | |
| const std::string & | getText (void) const |
| Obtains set text string buffer; defaults to \0. | |
| int32 | getFontWidth (void) const |
| Compute the width in pixels of the set text string; defaults to zero (0) | |
| int32 | getFontHeight (void) const |
| Compute the height in pixels of the set text string; defaults to zero (0) | |
| IFont::FontStyle | getFontStyle (void) const |
| const Color & | getColor (void) const |
| const Coords & | getPosition (void) const |
| uint32 | getNewline (void) const |
| Not implemented. | |
| uint32 | getSpacing (void) const |
| Not implemented. | |
| IFont::TextAlignment | getTextJustification (void) const |
| void | setFontStyle (int32 style, uint8 options=150) |
| void | setFontSize (int32 point_size) |
| Set a new text point size. | |
| void | setText (const std::string &text) |
| Set a new text string for drawing; defaults to \0. More... | |
| void | setColor (const Color &color) |
| void | setPosition (const Coords &coords) |
| void | setSpacing (uint32 spaces) |
| Not implemented. | |
| void | setTextJustification (IFont::TextAlignment alignment) |
| Not implemented. | |
| int32 | getFontOutline (void) const |
| Getter for obtaining the vector outline of the loaded font. | |
| void | setFontOutline (int32 depth) |
| Set a new vector outline – in pixels – for the loaded font. | |
| IFont::RenderStyle | getRenderingStyle (void) const |
| Getter for obtaining the current font rendering style in use. | |
| void | setRenderingStyle (IFont::RenderStyle) |
| Set a new font rendering style. | |
| bool | load (const std::string &filename, const Color &colorkey, bool use_cache=false) |
| Load a new font in from a file. More... | |
| void | update (void) |
| void | draw (SDL_Renderer *target) const |
| Draw the set text string to the video surface. | |
| void | draw (const Window &target) const |
Public Member Functions inherited from nom::IFont | |
| virtual bool | resize (enum ResizeAlgorithm scaling_algorithm) |
Public Member Functions inherited from nom::IDrawable | |
| IDrawable (void) | |
| Do nothing at all default constructor. | |
| virtual | ~IDrawable (void) |
| Do nothing at all destructor. | |
| virtual void | draw (RenderTarget) const =0 |
| Render the object onto the primary video buffer – your visible screen. | |
Private Member Functions | |
| bool | rebuild (void) |
Private Attributes | |
| Texture | font_buffer |
| Surface where font for drawing is rendered to. | |
| std::shared_ptr< TTF_Font > | font |
| Font file data, used by SDL_ttf extension. | |
| Coords | coords |
| Positioning coordinates (including width and height) | |
| Color | color |
| Text color. | |
| std::string | text_buffer |
| holds contents of text as a string buffer | |
| FontStyle | text_style |
| Current text effect set. | |
| uint8 | style_options |
| std::string | filename |
| Store the file path so we can change font sizes on the fly. | |
| int32 | font_size |
| Font point (pixel) size; defaults to 12. | |
| bool | use_cache |
| Whether or not to use caching features of nom::ObjectCache. | |
| enum IFont::TextAlignment | text_alignment |
| enum IFont::RenderStyle | rendering |
Additional Inherited Members | |
Public Types inherited from nom::IFont | |
| enum | FontStyle { Regular = 0, Bold = 1, Italic = 2, Underlined = 3, Faded = 4 } |
| Text effect styling. | |
| enum | TextAlignment { TopLeft = 0, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter, BottomRight } |
| enum | RenderStyle { NotImplemented = 0, Solid, Shaded, Blended } |
| Text rendering qualities. | |
| typedef IFont * | RawPtr |
| typedef std::unique_ptr< IFont > | UniquePtr |
| typedef std::shared_ptr< IFont > | SharedPtr |
Public Types inherited from nom::IDrawable | |
|
typedef std::unique_ptr < IDrawable > | UniquePtr |
| std::unique_ptr definition type for your convenience, sir! | |
|
typedef std::shared_ptr < IDrawable > | SharedPtr |
| std::shared_ptr definition type at your leisure, sir! | |
|
typedef std::vector < std::shared_ptr< IDrawable > > | SharedDrawables |
| Vector of std::shared_ptr definition type for the brotherhood, sir! | |
|
typedef std::vector < std::unique_ptr< IDrawable > > | UniqueDrawables |
| std::unique_ptr vector container type | |
| typedef const Window & | RenderTarget |
TrueType fonts renderer.
[TO BE WRITTEN]
Definition at line 50 of file TrueTypeFont.hpp.
|
virtual |
Load a new font in from a file.
Refer to the SDL_ttf documentation for file formats supported. As of this writing, TTF and FON file formats are known to be supported.
Implements nom::IFont.
Definition at line 237 of file TrueTypeFont.cpp.
|
private |
Trigger a rebuild of the font metrics from the current font; this recalculates character sizes, coordinate origins, spacing, etc.
Definition at line 323 of file TrueTypeFont.cpp.
|
virtual |
Text effect utilizing alpha channels for the appearance of gray text
Implements nom::IFont.
Definition at line 155 of file TrueTypeFont.cpp.
|
virtual |
Set a new text string for drawing; defaults to \0.
NOTE: We render the font drawing surface here
Implements nom::IFont.
Definition at line 214 of file TrueTypeFont.cpp.
|
virtual |
Intended to be used internally by the class re-implementing this method; for use in preparing the buffer to be drawn using the draw method call. Whereas both Update & Draw are typically publicly exposed to the end-user, only the Draw method call should be expected of the end-user to be explicitly called.
Implements nom::IDrawable.
Definition at line 258 of file TrueTypeFont.cpp.