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, const double a_letterSpacing)
 This method returns the width of a particular string using this font. More...
double getTextHeight (const std::string &a_text, const double a_lineSpacing)
 This method returns the heigth of a particular string using this font. More...
double renderText (const std::string &a_text, const cColorf &a_color, const double a_fontScale, const double a_letterSpacing, const double a_lineSpacing, cRenderOptions &a_options)
 This method renders a single string of text. More...

Static Public Member Functions

static cFontPtr create ()
 Shared cFont allocator. More...

Public Attributes

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

Destructor of class cFont.

Member Function Documentation

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

This method loads a font from the specified file.

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

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

a_textInput string.
a_letterSpacingLetter spacing factor
Width of input text.
double chai3d::cFont::getTextHeight ( const std::string &  a_text,
const double  a_lineSpacing 

This method returns the heigth of a particular string using this font.

a_textInput string.
a_lineSpacingLine spacing. Default value if 1.0
Height of input text.
double chai3d::cFont::renderText ( const std::string &  a_text,
const cColorf a_color,
const double  a_fontScale,
const double  a_letterSpacing,
const double  a_lineSpacing,
cRenderOptions a_options 

This method renders a single string and returns its length.

a_textString to be rendered.
a_colorFont Color
a_fontScaleFont scale factor
a_letterSpacingSpacing between letters
a_lineSpacingSpacing between lines
a_optionsRendering options.
Length of string.
void chai3d::cFont::parseFont ( std::istream &  a_stream,
cFontCharset &  a_charsetDesc 

This method parses a font from the specified stream.

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

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

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