OpenTTD
Public Member Functions | Private Member Functions | Private Attributes
SpriteFontCache Class Reference

Font cache for fonts that are based on a freetype font. More...

Inheritance diagram for SpriteFontCache:
FontCache

Public Member Functions

 SpriteFontCache (FontSize fs)
 Create a new sprite font cache.
 ~SpriteFontCache ()
 Free everything we allocated.
virtual SpriteID GetUnicodeGlyph (WChar key)
 Get the SpriteID mapped to the given key.
virtual void SetUnicodeGlyph (WChar key, SpriteID sprite)
 Map a SpriteID to the key.
virtual void InitializeUnicodeGlyphMap ()
 Initialize the glyph map.
virtual void ClearFontCache ()
 Clear the font cache.
virtual const SpriteGetGlyph (GlyphID key)
 Get the glyph (sprite) of the given key.
virtual uint GetGlyphWidth (GlyphID key)
 Get the width of the glyph with the given key.
virtual int GetHeight () const
 Get the height of the font.
virtual bool GetDrawGlyphShadow ()
 Do we need to draw a glyph shadow?
virtual GlyphID MapCharToGlyph (WChar key)
 Map a character into a glyph.
virtual const void * GetFontTable (uint32 tag, size_t &length)
 Read a font table from the font.
virtual const char * GetFontName ()
 Get the name of this font.
- Public Member Functions inherited from FontCache
 FontCache (FontSize fs)
 Create a new font cache.
virtual ~FontCache ()
 Clean everything up.
FontSize GetSize () const
 Get the FontSize of the font.
int GetAscender () const
 Get the ascender value of the font.
int GetDescender () const
 Get the descender value of the font.
int GetUnitsPerEM () const
 Get the units per EM value of the font.
bool HasParent ()
 Check whether the font cache has a parent.

Private Member Functions

void ClearGlyphToSpriteMap ()
 Clear the glyph to sprite mapping.

Private Attributes

SpriteID ** glyph_to_spriteid_map
 Mapping of glyphs to sprite IDs.

Additional Inherited Members

- Static Public Member Functions inherited from FontCache
static FontCacheGet (FontSize fs)
 Get the font cache of a given font size.
- Protected Attributes inherited from FontCache
FontCacheparent
 The parent of this font cache.
const FontSize fs
 The size of the font.
int height
 The height of the font.
int ascender
 The ascender value of the font.
int descender
 The descender value of the font.
int units_per_em
 The units per EM value of the font.

Detailed Description

Font cache for fonts that are based on a freetype font.

Definition at line 70 of file fontcache.cpp.

Constructor & Destructor Documentation

SpriteFontCache::SpriteFontCache ( FontSize  fs)

Create a new sprite font cache.

Parameters
fsThe font size to create the cache for.

Definition at line 95 of file fontcache.cpp.

References InitializeUnicodeGlyphMap().

Member Function Documentation

void SpriteFontCache::ClearFontCache ( )
virtual

Clear the font cache.

Implements FontCache.

Definition at line 170 of file fontcache.cpp.

References FontCache::fs, and Layouter::ResetFontCache().

bool SpriteFontCache::GetDrawGlyphShadow ( )
virtual

Do we need to draw a glyph shadow?

Returns
True if it has to be done, otherwise false.

Implements FontCache.

Definition at line 194 of file fontcache.cpp.

virtual const char* SpriteFontCache::GetFontName ( )
inlinevirtual

Get the name of this font.

Returns
The name of the font.

Implements FontCache.

Definition at line 88 of file fontcache.cpp.

virtual const void* SpriteFontCache::GetFontTable ( uint32  tag,
size_t &  length 
)
inlinevirtual

Read a font table from the font.

Parameters
tagThe of the table to load.
lengthThe length of the read data.
Returns
The loaded table data.

Implements FontCache.

Definition at line 87 of file fontcache.cpp.

const Sprite * SpriteFontCache::GetGlyph ( GlyphID  key)
virtual

Get the glyph (sprite) of the given key.

Parameters
keyThe key to look up.
Returns
The sprite.

Implements FontCache.

Definition at line 175 of file fontcache.cpp.

References GetUnicodeGlyph(), and ST_FONT.

uint SpriteFontCache::GetGlyphWidth ( GlyphID  key)
virtual

Get the width of the glyph with the given key.

Parameters
keyThe key to look up.
Returns
The width.

Implements FontCache.

Definition at line 182 of file fontcache.cpp.

References FontCache::fs, FS_NORMAL, GetUnicodeGlyph(), ScaleGUITrad(), and ST_FONT.

int SpriteFontCache::GetHeight ( ) const
virtual

Get the height of the font.

Returns
The height of the font.

Reimplemented from FontCache.

Definition at line 189 of file fontcache.cpp.

References FontCache::height, and ScaleGUITrad().

SpriteID SpriteFontCache::GetUnicodeGlyph ( WChar  key)
virtual

Get the SpriteID mapped to the given key.

Parameters
keyThe key to get the sprite for.
Returns
The sprite.

Implements FontCache.

Definition at line 108 of file fontcache.cpp.

References GB(), and glyph_to_spriteid_map.

Referenced by GetGlyph(), and GetGlyphWidth().

virtual GlyphID SpriteFontCache::MapCharToGlyph ( WChar  key)
inlinevirtual

Map a character into a glyph.

Parameters
keyThe character.
Returns
The glyph ID used to draw the character.

Implements FontCache.

Definition at line 86 of file fontcache.cpp.

void SpriteFontCache::SetUnicodeGlyph ( WChar  key,
SpriteID  sprite 
)
virtual

Map a SpriteID to the key.

Parameters
keyThe key to map to.
spriteThe sprite that is being mapped.

Implements FontCache.

Definition at line 114 of file fontcache.cpp.

References GB(), and glyph_to_spriteid_map.

Referenced by InitializeUnicodeGlyphMap().


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