Public Member Functions

wit::Font Class Reference

#include <wit/font.h>

List of all members.

Public Member Functions

 Font ()
 Font (const std::string &fontName, bool bold=false, bool italic=false)
 ~Font ()
void setChar (unsigned char symbol, int texWidth, int texHeight, char *data, int leftBearing, int width)
FontSymbol charData (unsigned char symbol) const
void registerFont (const std::string &fontName, bool bold, bool italic, int wordSpacing)
bool isValid () const
float draw (float x, float y, const std::string &text, const GXColor &color)

Detailed Description

The Font class encapsulates a set of glyphs.

Fonts are stored in a specialized format, with each character stored as an IA4 texture. This format allows text to be rendered very quickly. See the tools/font2wit application bundled with WIT to generate a WIT font resource from a TrueType font.

WIT comes bundled with one font, Sans16, which is only available in normal (non-bold, non-italic) style. This font is derived from Bitstream Vera Sans, copyright © 2003 by Bitstream, Inc. See src/Sans16.cpp for the full license of this font.

Note: The Font class currently only supports 7-bit ASCII text. Newlines, tab characters, other formatting characters, and word wrapping are currently unsupported. Characters outside the range of 32 (space) to 126 ("~") are replaced with spaces. These are all purely temporary limitations; support for UTF-8 is scheduled for a later release. However, support for characters outside of the ASCII range will require explicit support from the font.

Definition at line 20 of file font.h.


Constructor & Destructor Documentation

wit::Font::Font (  )

Creates a new, unregistered Font object with no glyphs.

Definition at line 120 of file font.cpp.

wit::Font::Font ( const std::string &  fontName,
bool  bold = false,
bool  italic = false 
)

Creates a new Font object loaded from an existing registered font.

If the requested font has not been registered, the object will be invalid.

See also:
isValid

Definition at line 133 of file font.cpp.

wit::Font::~Font (  )

Destroys the Font object.

Definition at line 151 of file font.cpp.


Member Function Documentation

FontSymbol wit::Font::charData ( unsigned char  symbol ) const

Returns a FontSymbol object containing information about the requested glyph from the font.

Definition at line 194 of file font.cpp.

float wit::Font::draw ( float  x,
float  y,
const std::string &  text,
const GXColor &  color 
)

Renders a string of text in the specified color at the specified location on the screen.

Definition at line 236 of file font.cpp.

bool wit::Font::isValid (  ) const

Returns true if the font is valid. A valid font is a font created with the default constructor or one that was successfully loaded from a registered font.

Definition at line 162 of file font.cpp.

void wit::Font::registerFont ( const std::string &  fontName,
bool  bold,
bool  italic,
int  wordSpacing 
)

Registers the current font with the specified name, style, and word spacing. Once a font has been registered it can be loaded using the constructor.

Definition at line 204 of file font.cpp.

void wit::Font::setChar ( unsigned char  symbol,
int  texWidth,
int  texHeight,
char *  data,
int  leftBearing,
int  width 
)

Sets the glyph for the specified character to the (texWidth) x (texHeight) texture pointed to by data. The character is given the specified left bearing and advance width.

The buffer pointed to by data must remain valid for the lifetime of the application.

Definition at line 174 of file font.cpp.


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