OpenGUI::FontSet Class Reference

#include <OpenGUI_FontSet.h>

Inheritance diagram for OpenGUI::FontSet:

OpenGUI::RefObject List of all members.

Detailed Description

Used to load fonts and render glyphs from those fonts into memory segments.


Public Member Functions

const std::string & getFilename ()
 Returns the filename used to load the font.
const std::string & getName ()
 Returns the name of this font.
bool getGlyph (const char glyph_charCode, const IVector2 &pixelSize, FontGlyph &outFontGlyph)
 Retrieves the imagery backing a font glyph, as well as a pixel based rect defining the glyph extents.
unsigned int getLineSpacing (unsigned int pointSize)
 Returns the line height in pixels for a given pixelSizeY.
int getAscender (unsigned int pointSize)
 Returns the font wide ascender in pixels for a given pointSize.
int getDescender (unsigned int pointSize)
 Returns the font wide descender in pixels for a given pointSize.
int getMaxAdvance (unsigned int pointSize)
 Returns the maximum horizontal advance for all characters at the given pointSize.
int getTextWidth (const IVector2 &pixelSize, const std::string &text)
 Returns the true width for the given text at the given pointSize.
void renderGlyph (char glyph_charCode, const IVector2 &pixelSize, TextureDataRect *destTDR, FontGlyphMetrics &destGlyphMetrics)
 Renders the requested glyph to the given TextureDataRect in the size specified.

Protected Member Functions

 FontSet (const std::string &sourceFilename, const std::string &fontName)
 Font creation implies loading of the font via FreeType.
 ~FontSet ()
 Destruction also unloads the font from FreeType.
virtual void finalize ()
 This is called when the last handle to this object is destroyed.


Constructor & Destructor Documentation

OpenGUI::FontSet::FontSet ( const std::string &  sourceFilename,
const std::string &  fontName 
) [protected]

Font creation implies loading of the font via FreeType.

Parameters:
sourceFilename filename of the font to load
fontName the friendly name for this FontSet

OpenGUI::FontSet::~FontSet (  )  [protected]

Destruction also unloads the font from FreeType.


Member Function Documentation

void OpenGUI::FontSet::finalize (  )  [protected, virtual]

This is called when the last handle to this object is destroyed.

Implements OpenGUI::RefObject.

int OpenGUI::FontSet::getAscender ( unsigned int  pointSize  ) 

Returns the font wide ascender in pixels for a given pointSize.

int OpenGUI::FontSet::getDescender ( unsigned int  pointSize  ) 

Returns the font wide descender in pixels for a given pointSize.

const std::string& OpenGUI::FontSet::getFilename (  )  [inline]

Returns the filename used to load the font.

bool OpenGUI::FontSet::getGlyph ( const char  glyph_charCode,
const IVector2 pixelSize,
FontGlyph &  outFontGlyph 
)

Retrieves the imagery backing a font glyph, as well as a pixel based rect defining the glyph extents.

Returns:
true on success, false if the glyph cannot be generated because of some FreeType error
Parameters:
glyph_charCode The character code (currently ASCII) of the glyph you are requesting
pixelSize The size of the glyph you'd like, in pixels. Translation to/from pixels is up to the user. (See: Screen::getPPU(), Screen::getUPI())
outFontGlyph On success, this is initialized with information about the glyph.
The imagery provided by outImageryPtr will provide pixel alignment if the glyph is drawn to the screen in the exact size as outPixelRect. It is up to the user to provide this last stage pixel alignment. In most cases, users should use the PrimitiveText object to generate their text output, as it will perform the necessary steps to provide pixel alignment.

unsigned int OpenGUI::FontSet::getLineSpacing ( unsigned int  pointSize  ) 

Returns the line height in pixels for a given pixelSizeY.

int OpenGUI::FontSet::getMaxAdvance ( unsigned int  pointSize  ) 

Returns the maximum horizontal advance for all characters at the given pointSize.

const std::string& OpenGUI::FontSet::getName (  )  [inline]

Returns the name of this font.

int OpenGUI::FontSet::getTextWidth ( const IVector2 pixelSize,
const std::string &  text 
)

Returns the true width for the given text at the given pointSize.

void OpenGUI::FontSet::renderGlyph ( char  glyph_charCode,
const IVector2 pixelSize,
TextureDataRect destTDR,
FontGlyphMetrics &  destGlyphMetrics 
)

Renders the requested glyph to the given TextureDataRect in the size specified.

Note:
The TextureDataRect will be resized to exactly hold the glyph. destGlyphMetrics will contain the glyph metrics in pixels for the glyph at the requested size
Remarks:
This function is used by the FontCache to generate glyphs for storage in FontAtlases so that they can be renderer to the screen.
See also:
Most users are probably looking for PrimitiveText, or at the most getGlyph().


The documentation for this class was generated from the following files:
Copyright © 2006 OpenGUI | OpenGUI.SF.net
Generated: Fri Jan 5 23:05:25 2007