chai3d::cFont Class Reference

This class implements support for 2D fonts. More...

#include <CFont.h>

Public Member Functions

 cFont ()
 Constructor of cFont. More...
 
virtual ~cFont ()
 Destructor of cFont. More...
 
bool loadFromFile (const std::string &a_filename)
 This method loads a font file by passing a path and file name as argument. More...
 
std::string getFilename () const
 This method returns the filename from which this font was last loaded or saved. More...
 
double getPointSize () const
 This method returns the current font size. More...
 
double getTextWidth (const std::string &a_text)
 This method returns the width of a particular string using this font. More...
 
double renderText (const std::string &a_text, const cColorf &a_color, const double a_fontScale, cRenderOptions &a_options)
 This method render a single string of text. More...
 

Public Attributes

cTexture2d * m_texture
 Texture image containing the full bitmap representation of the font. More...
 
cFontCharset m_charset
 Information about each character in the set. More...
 

Protected Member Functions

void parseFont (std::istream &a_stream, cFontCharset &a_charsetDesc)
 This method parses a font file. More...
 
void cleanup ()
 This method cleans all memory. More...
 

Protected Attributes

std::string m_filename
 Current font filename loaded into memory. More...
 

Detailed Description

This class provides support for font files generated from AngelSoft's Bitmap Font Generator application. This program will allow you to generate bitmap fonts from TrueType fonts. The application generates both image files and character descriptions that can be read by a game for easy rendering of fonts. These files can then be loaded into the cFont class by using the loadFromFile() method.

Constructor & Destructor Documentation

chai3d::cFont::cFont ( )

Constructor of class cFont.

chai3d::cFont::~cFont ( )
virtual

Destructor of class cFont.

Member Function Documentation

bool chai3d::cFont::loadFromFile ( const std::string &  a_filename)

This method loads a font from the specified file.

Parameters
a_filenameFont filename.
std::string chai3d::cFont::getFilename ( ) const
inline
double chai3d::cFont::getPointSize ( ) const
inline
double chai3d::cFont::getTextWidth ( const std::string &  a_text)

This method computes the width of a string a_text passed as argument.

Parameters
a_textInput string.
Returns
Width of input text.
double chai3d::cFont::renderText ( const std::string &  a_text,
const cColorf &  a_color,
const double  a_fontScale,
cRenderOptions &  a_options 
)

This method renders a single string and returns its length.

Parameters
a_textString to be rendered.
a_colorFont Color
a_fontScaleFont scale factor
a_optionsRendering options.
Returns
Length of string.
void chai3d::cFont::parseFont ( std::istream &  a_stream,
cFontCharset &  a_charsetDesc 
)
protected

This method parses a font from the specified stream.

Parameters
a_streamFont filename
a_charsetDescDescription of the new charset.
void chai3d::cFont::cleanup ( )
protected

This method cleans up all data structures.

Member Data Documentation

cTexture2d* chai3d::cFont::m_texture
cFontCharset chai3d::cFont::m_charset
std::string chai3d::cFont::m_filename
protected

The documentation for this class was generated from the following files: