Font

Simple OO wrapper around a TrueType font that can be drawn to textures and rendered via OpenGL.

Since Font is a child of ResourceManaged, all memory management is taken care of.

Operators

  • Font = Font
  • bool : True if font is loaded, false if not.
  • ostream& << Font
Summary
Simple OO wrapper around a TrueType font that can be drawn to textures and rendered via OpenGL.
Default constructor, initalizes internal state of Font.
Copy constructor, copies another Font.
Initializing constructor, loads Font via call to open.
Opens an TrueType font.
Determine status of Font.
Set draw color of the font.
Get draw color of the font.
Define a new named resource.
Define a new unaliased resource.

(Con/ De)structors

Font

Font()

Default constructor, initalizes internal state of Font.

Font

Font(const Font &rhs)

Copy constructor, copies another Font.

Parameters

rhsFont to construct copy of.

Font

Font(const std::string &name)

Initializing constructor, loads Font via call to open.

Parameters

nameName of the Font <Resource> to open.

See Also

open

General

open

void open(const std::string &name)

Opens an TrueType font.

Loading is done via FreeType.

Parameters

nameName of the Font <Resource> to open.

isValid

bool isValid() const

Determine status of Font.

Returns

True if font is loaded, false if font is not loaded/initialized.

Coloring

setColor

void setColor(const Color &color)

Set draw color of the font.

Parameters

colorColor to shade font glyphs when drawn.

getColor

Color getColor() const

Get draw color of the font.

Returns

Currently set Color to shade font glyphs when drawn.

Drawing

Font Metrics

Resource Creation

addResource

static void addResource(const std::string &name,
const std::string &path,
uint size)

Define a new named resource.  (Ex.  Image::addResource(“monkey”,”images/monkey.png”) would make it so that any attempts to load “monkey” would load the image images/monkey.png)

Parameters

nameName to give to resource.
pathPath of resource data file.

addResource

static void addResource(const std::string &path,
uint size)

Define a new unaliased resource.  (name == path).  (Ex.  Image::addResource(“images/monkey.png”) is essentially the same as Image::addResource(“images/monkey.png”,”images/monkey.png”)

Parameters:. path - Path of resource data file.

Font()
Default constructor, initalizes internal state of Font.
void open(const std::string &name)
Opens an TrueType font.
bool isValid() const
Determine status of Font.
void setColor(const Color &color)
Set draw color of the font.
Color getColor() const
Get draw color of the font.
static void addResource(const std::string &name,
const std::string &path,
uint size)
Define a new named resource.
Base template class, to be used as a base from which classes which have resources that can be controlled, such as textures and music, can be derived.
Class for storing components of a color.