OpenTTD Source
20241125-master-g5b02f51e17
|
Font cache for basic fonts. More...
#include <fontcache.h>
Public Member Functions | |
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... | |
virtual int | GetFontSize () const |
Get the nominal font size of the font. More... | |
virtual void | SetUnicodeGlyph (char32_t key, SpriteID sprite)=0 |
Map a SpriteID to the key. More... | |
virtual void | InitializeUnicodeGlyphMap ()=0 |
Initialize the glyph map. | |
virtual void | ClearFontCache ()=0 |
Clear the font cache. | |
virtual const Sprite * | GetGlyph (GlyphID key)=0 |
Get the glyph (sprite) of the given key. More... | |
virtual uint | GetGlyphWidth (GlyphID key)=0 |
Get the width of the glyph with the given key. More... | |
virtual bool | GetDrawGlyphShadow ()=0 |
Do we need to draw a glyph shadow? More... | |
virtual GlyphID | MapCharToGlyph (char32_t key, bool fallback=true)=0 |
Map a character into a glyph. More... | |
virtual const void * | GetOSHandle () |
Get the native OS font handle, if there is one. More... | |
virtual std::string | GetFontName ()=0 |
Get the name of this font. More... | |
bool | HasParent () |
Check whether the font cache has a parent. | |
virtual bool | IsBuiltInFont ()=0 |
Is this a built-in sprite font? | |
Static Public Member Functions | |
static void | InitializeFontCaches () |
static int | GetDefaultFontHeight (FontSize fs) |
static FontCache * | Get (FontSize fs) |
Get the font cache of a given font size. More... | |
static std::string | GetName (FontSize fs) |
Get the font name of a given font size. More... | |
Protected Attributes | |
FontCache * | parent |
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. | |
Static Protected Attributes | |
static FontCache * | caches [FS_END] |
All the font caches. | |
Font cache for basic fonts.
Definition at line 21 of file fontcache.h.
FontCache::FontCache | ( | FontSize | fs | ) |
Create a new font cache.
fs | The size of the font. |
Definition at line 35 of file fontcache.cpp.
Get the font cache of a given font size.
fs | The font size to look up. |
Definition at line 129 of file fontcache.h.
References fs.
Referenced by MissingGlyphSearcher::FindMissingGlyphs(), GetCharacterHeight(), GetGlyph(), GetGlyphWidth(), GetName(), SetUnicodeGlyph(), and SurveyFont().
|
inline |
Get the ascender value of the font.
Definition at line 54 of file fontcache.h.
References ascender.
|
inline |
Get the descender value of the font.
Definition at line 60 of file fontcache.h.
References descender.
|
pure virtual |
Do we need to draw a glyph shadow?
Implemented in MockFontCache, TrueTypeFontCache, and SpriteFontCache.
|
pure virtual |
Get the name of this font.
Implemented in MockFontCache, Win32FontCache, CoreTextFontCache, SpriteFontCache, and FreeTypeFontCache.
Referenced by GetName(), HFontFromFont(), and SurveyFont().
|
inlinevirtual |
Get the nominal font size of the font.
Reimplemented in TrueTypeFontCache.
Definition at line 66 of file fontcache.h.
References height.
Get the glyph (sprite) of the given key.
key | The key to look up. |
Implemented in MockFontCache, TrueTypeFontCache, and SpriteFontCache.
Referenced by GetGlyph().
|
pure virtual |
Get the width of the glyph with the given key.
key | The key to look up. |
Implemented in MockFontCache, TrueTypeFontCache, and SpriteFontCache.
Referenced by GetGlyphWidth().
|
inline |
Get the height of the font.
Definition at line 48 of file fontcache.h.
References height.
Referenced by GetCharacterHeight(), and HFontFromFont().
|
static |
Get the font name of a given font size.
fs | The font size to look up. |
Definition at line 61 of file fontcache.cpp.
References fs, Get(), and GetFontName().
|
inlinevirtual |
Get the native OS font handle, if there is one.
Reimplemented in Win32FontCache, CoreTextFontCache, and FreeTypeFontCache.
Definition at line 113 of file fontcache.h.
Referenced by HFontFromFont().
|
inline |
Get the FontSize of the font.
Definition at line 42 of file fontcache.h.
References fs.
Referenced by UniscribeShapeRun().
|
pure virtual |
Map a character into a glyph.
key | The character. |
fallback | Allow fallback to the parent font. |
Implemented in Win32FontCache, CoreTextFontCache, SpriteFontCache, and FreeTypeFontCache.
Referenced by GetGlyph(), and GetGlyphWidth().
|
pure virtual |
Map a SpriteID to the key.
key | The key to map to. |
sprite | The sprite that is being mapped. |
Implemented in MockFontCache, TrueTypeFontCache, and SpriteFontCache.
Referenced by TrueTypeFontCache::SetUnicodeGlyph(), and SetUnicodeGlyph().