Font Class Reference

The Font resource class. More...

#include <Graphics/Font.h>

Inherits Resource< int >.

List of all members.

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")

Detailed Description

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.


Member Enumeration Documentation

defines the differant types of font alignment when drawing a string.

Enumerator:
ALIGN_NONE 

No alignment

ALIGN_TOP 

Top center alignment

ALIGN_TOP_LEFT 

Top left alignemnt

ALIGN_TOP_RIGHT 

Top right alignment

ALIGN_CENTER 

Center alignment

ALIGN_LEFT 

Left center alignment

ALIGN_RIGHT 

Right center alignment

ALIGN_BOTTOM 

Bottom center alignment

ALIGN_BOTTOM_LEFT 

Bottom left alignment

ALIGN_BOTTOM_RIGHT 

Bottom right alignment


Constructor & Destructor Documentation

Font::~Font (  ) 

The path to the default font.


Member Function Documentation

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.

Parameters:
[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.
void Font::DrawTextStr ( const char *  str,
const Color4f c,
const Point2f p 
) const

Draws a string of text.

Parameters:
[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.

Parameters:
[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.
Returns:
The position in absolute screen coordinates where str should be drawn to meet the alignment and area criterion.
float Font::LineHeight (  )  const

Gets the maximum height for all characters in the font.

Returns:
The maximum height for all characters in the font in absolute screen coordinates.
void Font::StringDimensions ( const char *  str,
float &  w,
float &  h 
) const

Gets the width and height of the given string in absolute screen coordinates.

Parameters:
[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.

Parameters:
[in] str string to determine the height of.
Returns:
The height of str in absolute screen coordinates.
float Font::StringWidth ( const char *  str  )  const

Gets the width of the given string in absolute screen coordinates.

Parameters:
[in] str string to determine the with of.
Returns:
The width of str in absolute screen coordinates.

Member Data Documentation

const std::string Font::DEFAULT_FONT_PATH = CreatePath("VeraMono.ttf") [static]

The default font size.


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 19:08:05 2010 for BrickOut |ReDuX| by  doxygen 1.6.3