OpenTTD Source  13.2.1
SpriteFontCache Class Reference

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

#include <spritefontcache.h>

Inheritance diagram for SpriteFontCache:
FontCache

Public Member Functions

 SpriteFontCache (FontSize fs)
 Create a new sprite font cache. More...
 
 ~SpriteFontCache ()
 Free everything we allocated.
 
virtual void SetUnicodeGlyph (WChar key, SpriteID sprite)
 Map a SpriteID to the key. More...
 
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. More...
 
virtual uint GetGlyphWidth (GlyphID key)
 Get the width of the glyph with the given key. More...
 
virtual bool GetDrawGlyphShadow ()
 Do we need to draw a glyph shadow? More...
 
virtual GlyphID MapCharToGlyph (WChar key)
 Map a character into a glyph. More...
 
virtual const void * GetFontTable (uint32 tag, size_t &length)
 Read a font table from the font. More...
 
virtual std::string GetFontName ()
 Get the name of this font. More...
 
virtual bool IsBuiltInFont ()
 Is this a built-in sprite font?
 
- Public Member Functions inherited from FontCache
 FontCache (FontSize fs)
 Create a new font cache. More...
 
virtual ~FontCache ()
 Clean everything up.
 
FontSize GetSize () const
 Get the FontSize of the font. More...
 
int GetHeight () const
 Get the height of the font. More...
 
int GetAscender () const
 Get the ascender value of the font. More...
 
int GetDescender () const
 Get the descender value of the font. More...
 
int GetUnitsPerEM () const
 Get the units per EM value of the font. More...
 
virtual int GetFontSize () const
 Get the nominal font size of the font. More...
 
virtual const void * GetOSHandle ()
 Get the native OS font handle, if there is one. More...
 
bool HasParent ()
 Check whether the font cache has a parent.
 

Private Member Functions

SpriteID GetUnicodeGlyph (WChar key)
 
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 int GetDefaultFontHeight (FontSize fs)
 
static FontCacheGet (FontSize fs)
 Get the font cache of a given font size. More...
 
- 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 17 of file spritefontcache.h.

Constructor & Destructor Documentation

◆ SpriteFontCache()

SpriteFontCache::SpriteFontCache ( FontSize  fs)

Create a new sprite font cache.

Parameters
fsThe font size to create the cache for.

Definition at line 28 of file spritefontcache.cpp.

References FontCache::ascender, FontCache::height, InitializeUnicodeGlyphMap(), ScaleGUITrad(), and ScaleSpriteTrad().

Member Function Documentation

◆ GetDrawGlyphShadow()

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 126 of file spritefontcache.cpp.

◆ GetFontName()

virtual std::string SpriteFontCache::GetFontName ( )
inlinevirtual

Get the name of this font.

Returns
The name of the font.

Implements FontCache.

Definition at line 34 of file spritefontcache.h.

◆ GetFontTable()

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 33 of file spritefontcache.h.

◆ GetGlyph()

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 112 of file spritefontcache.cpp.

◆ GetGlyphWidth()

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 119 of file spritefontcache.cpp.

◆ MapCharToGlyph()

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 32 of file spritefontcache.h.

◆ SetUnicodeGlyph()

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 49 of file spritefontcache.cpp.

References GB(), and glyph_to_spriteid_map.


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