Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | Static Public Member Functions | List of all members
om::graphics::gui::fonts::FontManager Class Reference

A class that allows the user to enumerate and search through the installed system fonts. More...

#include <omGraphicsGUIFontManager.h>

Public Member Functions

 FontManager ()
 Create a default font manager with the default search paths that hasn't yet cached any fonts. More...
 
Size getFontCount () const
 Return the total number of system fonts that are available for use. More...
 
const FontIDgetFontID (Index fontIndex) const
 Return the ID of the cached font at the specified index in this font manager. More...
 
const FontIDfindFontID (const UTF8String &familyName) const
 Find a system font which has the specified font family name. More...
 
const FontIDfindFontID (const UTF8String &familyName, const UTF8String &styleName) const
 Find a system font which has the specified font family name and specified style name. More...
 
Shared< FontfindFont (const UTF8String &familyName) const
 Find a system font which has the specified font family name. More...
 
Shared< FontfindFont (const UTF8String &familyName, const UTF8String &styleName) const
 Find a system font which has the specified font family name and specified style name. More...
 
Size getPathCount () const
 Return the number of font search directories there are in this font manager. More...
 
const UTF8String & getPath (Index pathIndex) const
 Return a reference to the search path string at the specified index in this font manager. More...
 
void addPath (const UTF8String &newPath)
 Add a new search path with the given string to this font manager. More...
 
void clearPaths ()
 Remove all search paths from this font manager. More...
 
void refreshFonts ()
 Search the system for valid font files and cache their locations and names. More...
 

Static Public Member Functions

static const FontIDgetDefaultFont ()
 Return a reference to information about the default font. More...
 

Detailed Description

A class that allows the user to enumerate and search through the installed system fonts.

When the information is first needed, the font manager automatically caches the system's available fonts by searching system directories for font files, then saving each valid file's path and information so that it can be later used. Keep in mind that this this caching can take a few seconds to occur.

The font manager then allows the user to search for fonts with a certain font family and style name within the cached fonts.

Constructor & Destructor Documentation

om::graphics::gui::fonts::FontManager::FontManager ( )

Create a default font manager with the default search paths that hasn't yet cached any fonts.

Member Function Documentation

Size om::graphics::gui::fonts::FontManager::getFontCount ( ) const

Return the total number of system fonts that are available for use.

const FontID& om::graphics::gui::fonts::FontManager::getFontID ( Index  fontIndex) const

Return the ID of the cached font at the specified index in this font manager.

The fonts are sorted in ascending alphabetical order by family and then style name.

const FontID* om::graphics::gui::fonts::FontManager::findFontID ( const UTF8String &  familyName) const
inline

Find a system font which has the specified font family name.

The method attempts to match the family name when determining the font to retrieve. If the method finds a suitable font, a non-NULL pointer to a FontID is returned. Otherwise, if the method fails, NULL is returned indicating that no font with that name was found.

const FontID* om::graphics::gui::fonts::FontManager::findFontID ( const UTF8String &  familyName,
const UTF8String &  styleName 
) const
inline

Find a system font which has the specified font family name and specified style name.

If the style name pointer is not NULL, the method attempts to match both the family name and style name when determining the font to retrieve. If the method finds a suitable font, a non-NULL pointer to a FontID is returned. Otherwise, if the method fails, NULL is returned indicating that no font with those names was found.

Shared<Font> om::graphics::gui::fonts::FontManager::findFont ( const UTF8String &  familyName) const
inline

Find a system font which has the specified font family name.

The method attempts to match the family name when determining the font to retrieve. If the method finds a suitable font, a non-NULL shared pointer to a Font is returned. Otherwise, if the method fails, NULL is returned indicating that no font with that name was found.

Shared<Font> om::graphics::gui::fonts::FontManager::findFont ( const UTF8String &  familyName,
const UTF8String &  styleName 
) const
inline

Find a system font which has the specified font family name and specified style name.

If the style name pointer is not NULL, the method attempts to match both the family name and style name when determining the font to retrieve. If the method finds a suitable font, a non-NULL shared pointer to a Font is returned. Otherwise, if the method fails, NULL is returned indicating that no font with that name was found.

Size om::graphics::gui::fonts::FontManager::getPathCount ( ) const
inline

Return the number of font search directories there are in this font manager.

These directories are scanned recursively for valid font files by the font manager when it refreshes its cached font info.

const UTF8String& om::graphics::gui::fonts::FontManager::getPath ( Index  pathIndex) const
inline

Return a reference to the search path string at the specified index in this font manager.

These directories are scanned recursively for valid font files by the font manager when it refreshes its cached font info.

void om::graphics::gui::fonts::FontManager::addPath ( const UTF8String &  newPath)

Add a new search path with the given string to this font manager.

This directory will be scanned recursively for valid font files by the font manager when it refreshes its cached font info.

void om::graphics::gui::fonts::FontManager::clearPaths ( )

Remove all search paths from this font manager.

void om::graphics::gui::fonts::FontManager::refreshFonts ( )

Search the system for valid font files and cache their locations and names.

Calling this method replaces all previously cached fonts with the current set of available system fonts. Beware, calling this method may take a significant time to execute (on the order of a few seconds) if there are a large number of fonts installed because the font manager has to examine every font file to determine the font's name and style name.

static const FontID* om::graphics::gui::fonts::FontManager::getDefaultFont ( )
static

Return a reference to information about the default font.

This font will be a valid font file, chosen to match the system's default font.


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