blip  0.1
FontManager Class Reference

A class for loading and caching TrueType fonts. More...

#include <FontManager.hpp>

Public Member Functions

 FontManager (uint_t fontCacheSize=4, uint_t glyphCacheSize=96)
 Construct a new FontManager with the given cache sizes. More...
 
 ~FontManager ()
 Destructor. More...
 
void loadFont (ccxx::DataReader *reader, int size, int index=0)
 Load a font from a DataReader. More...
 
const FontlookupFont (const ccxx::String &name, int size, int style=0) const
 Look up a font previously loaded with loadFont(). More...
 

Detailed Description

A class for loading and caching TrueType fonts.

The class uses the FreeType library to decode the fonts. Fonts can be loaded from files, from memory buffers, or from Android asset files.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ FontManager()

FontManager ( uint_t  fontCacheSize = 4,
uint_t  glyphCacheSize = 96 
)

Construct a new FontManager with the given cache sizes.

Parameters
fontCacheSizeThe size of the LRU font cache; this is the maximum number of distinct font faces that may be in memory at any one time.
glyphCacheSizeThe size of the LRU glyph cache; this is the maximum number of character glyphs that may be in memory for each font face at any one time.

◆ ~FontManager()

Destructor.

Member Function Documentation

◆ loadFont()

void loadFont ( ccxx::DataReader *  reader,
int  size,
int  index = 0 
)

Load a font from a DataReader.

The font is added to the internal LRU cache, possibly evicting another font if the cache is already full.

Parameters
readerThe DataReader to read the font from. The FontManager takes ownership of the DataReader, which will remain in use as long as glyphs need to be read from the font file. The caller should not release the data resource that is backing this DataReader.
sizeThe desired point size.
indexThe font face index, if the font file contains more than one font face. Normally this should be 0.
Exceptions
IOExceptionIf an error occurred while reading the font.

◆ lookupFont()

const Font * lookupFont ( const ccxx::String &  name,
int  size,
int  style = 0 
) const

Look up a font previously loaded with loadFont().

Parameters
nameThe name of the font face.
sizeThe font's point size.
styleThe font's style; either Font::PLAIN or a bitwise OR of Font::BOLD and Font::ITALIC.
Returns
A pointer to the Font object, if found, otherwise NULL.

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