The Font resource class. More...
#include <Graphics/Font.h>
Inherits Resource< int >.
Public Types | |
enum | TextAlignment { ALIGN_NONE = 0, ALIGN_TOP, ALIGN_TOP_LEFT, ALIGN_TOP_RIGHT, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_BOTTOM_LEFT, ALIGN_BOTTOM_RIGHT } |
defines the differant types of font alignment when drawing a string. More... | |
Public Member Functions | |
~Font () | |
virtual void | Destroy () |
Destroys the resource. | |
float | StringWidth (const char *str) const |
Gets the width of the given string in absolute screen coordinates. | |
float | StringHeight (const char *str) const |
Gets the height of the given string in absolute screen coordinates. | |
void | StringDimensions (const char *str, float &w, float &h) const |
Gets the width and height of the given string in absolute screen coordinates. | |
float | LineHeight () const |
Gets the maximum height for all characters in the font. | |
Point2f | GetTextPosition (const char *str, const Rectf &area, TextAlignment align, const Point2f &offset=Point2f(0.0f, 0.0f)) const |
Determines the position to draw a string given some alignment and area criterion. | |
void | DrawTextStr (const char *str, const Color4f &c, const Point2f &p) const |
Draws a string of text. | |
void | DrawTextStr (const char *str, const Color4f &c, const Rectf &area, TextAlignment align, const Point2f &offset=Point2f(0.0f, 0.0f)) const |
Draws a string of aligned text. | |
Static Public Attributes | |
static const std::string | DEFAULT_FONT_PATH = CreatePath("VeraMono.ttf") |
The Font resource class.
A resource type that is used for loading and drawing true type fonts. All coordinates given or created by the Font class are assumed to be in absolute screen coordinates unless otherwise noted.
enum Font::TextAlignment |
defines the differant types of font alignment when drawing a string.
Font::~Font | ( | ) |
The path to the default font.
void Font::Destroy | ( | ) | [virtual] |
Destroys the resource.
Deallocates all data allocated when the resource was loaded. Must be implemented by all classes that inherit from the Resource class but should never be called outside of the ResourceMgr class.
Implements Resource< int >.
void Font::DrawTextStr | ( | const char * | str, | |
const Color4f & | c, | |||
const Rectf & | area, | |||
TextAlignment | align, | |||
const Point2f & | offset = Point2f(0.0f, 0.0f) | |||
) | const |
Draws a string of aligned text.
[in] | str | the string to draw. |
[in] | c | the color to draw this string. |
[in] | area | the Rect str is expected to be drawn into. |
[in] | align | the alignment of str within area. |
[in] | offset | the ammount to offset str from its given alignment. |
Draws a string of text.
[in] | str | the string to draw. |
[in] | c | the color to draw this string. |
[in] | p | the top left corner where str will be drawn. |
Point2f Font::GetTextPosition | ( | const char * | str, | |
const Rectf & | area, | |||
TextAlignment | align, | |||
const Point2f & | offset = Point2f(0.0f, 0.0f) | |||
) | const |
Determines the position to draw a string given some alignment and area criterion.
[in] | str | the string of text. |
[in] | area | the rectance where the text is to sit. |
[in] | align | the type of alignment to use. |
[in] | offset | the amount to offset from the final computed position. |
float Font::LineHeight | ( | ) | const |
Gets the maximum height for all characters in the font.
void Font::StringDimensions | ( | const char * | str, | |
float & | w, | |||
float & | h | |||
) | const |
Gets the width and height of the given string in absolute screen coordinates.
[in] | str | string to determine the with and height of. |
[out] | w | is set to the width of str in absolute screen coordinates. |
[out] | h | is set to the height of str in absolute screen coordinates. |
float Font::StringHeight | ( | const char * | str | ) | const |
Gets the height of the given string in absolute screen coordinates.
[in] | str | string to determine the height of. |
float Font::StringWidth | ( | const char * | str | ) | const |
Gets the width of the given string in absolute screen coordinates.
[in] | str | string to determine the with of. |
const std::string Font::DEFAULT_FONT_PATH = CreatePath("VeraMono.ttf") [static] |
The default font size.