OpenTTD Source 20250724-master-g7eb042feac
|
Font cache for basic fonts. More...
#include <fontcache.h>
Public Member Functions | |
FontCache (FontSize fs) | |
Create a new font cache. | |
virtual | ~FontCache () |
Clean everything up. | |
FontSize | GetSize () const |
Get the FontSize of the font. | |
int | GetHeight () const |
Get the height of the font. | |
int | GetAscender () const |
Get the ascender value of the font. | |
int | GetDescender () const |
Get the descender value of the font. | |
virtual int | GetFontSize () const |
Get the nominal font size of the font. | |
virtual void | ClearFontCache ()=0 |
Clear the font cache. | |
virtual const Sprite * | GetGlyph (GlyphID key)=0 |
Get the glyph (sprite) of the given key. | |
virtual uint | GetGlyphWidth (GlyphID key)=0 |
Get the width of the glyph with the given key. | |
virtual bool | GetDrawGlyphShadow ()=0 |
Do we need to draw a glyph shadow? | |
virtual GlyphID | MapCharToGlyph (char32_t key, bool fallback=true)=0 |
Map a character into a glyph. | |
virtual const void * | GetOSHandle () |
Get the native OS font handle, if there is one. | |
virtual std::string | GetFontName ()=0 |
Get the name of this font. | |
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. | |
static std::string | GetName (FontSize fs) |
Get the font name of a given font size. | |
Static Public Attributes | |
static const int | DEFAULT_FONT_HEIGHT [FS_END] = {10, 6, 18, 10} |
Default unscaled font heights. | |
static const int | DEFAULT_FONT_ASCENDER [FS_END] = {8, 5, 15, 8} |
Default unscaled font ascenders. | |
Protected Attributes | |
FontCache * | parent |
The parent of this font cache. | |
const FontSize | fs |
The size of the font. | |
int | height = 0 |
The height of the font. | |
int | ascender = 0 |
The ascender value of the font. | |
int | descender = 0 |
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 36 of file fontcache.cpp.
References caches, fs, parent, and Layouter::ResetFontCache().
|
virtual |
Clean everything up.
Definition at line 44 of file fontcache.cpp.
References caches, fs, parent, and Layouter::ResetFontCache().
|
pure virtual |
Clear the font cache.
Implemented in FreeTypeFontCache, SpriteFontCache, TrueTypeFontCache, CoreTextFontCache, Win32FontCache, and MockFontCache.
Get the font cache of a given font size.
fs | The font size to look up. |
Definition at line 124 of file fontcache.h.
Referenced by MissingGlyphSearcher::FindMissingGlyphs(), GetCharacterHeight(), GetGlyph(), GetGlyphWidth(), GetName(), InitFontCache(), SurveyFont(), and UninitFontCache().
|
inline |
Get the ascender value of the font.
Definition at line 59 of file fontcache.h.
References ascender.
Referenced by FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun().
|
static |
Definition at line 51 of file fontcache.cpp.
|
inline |
Get the descender value of the font.
Definition at line 65 of file fontcache.h.
References descender.
|
pure virtual |
Do we need to draw a glyph shadow?
Implemented in SpriteFontCache, TrueTypeFontCache, and MockFontCache.
Referenced by DrawLayoutLine().
|
pure virtual |
Get the name of this font.
Implemented in FreeTypeFontCache, SpriteFontCache, CoreTextFontCache, Win32FontCache, and MockFontCache.
Referenced by GetName(), HFontFromFont(), and SurveyFont().
|
inlinevirtual |
Get the nominal font size of the font.
Reimplemented in TrueTypeFontCache.
Definition at line 71 of file fontcache.h.
References height.
Get the glyph (sprite) of the given key.
key | The key to look up. |
Implemented in SpriteFontCache, TrueTypeFontCache, and MockFontCache.
Referenced by DrawLayoutLine(), GetGlyph(), and TrueTypeFontCache::GetGlyph().
|
pure virtual |
Get the width of the glyph with the given key.
key | The key to look up. |
Implemented in SpriteFontCache, TrueTypeFontCache, and MockFontCache.
Referenced by FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(), GetGlyphWidth(), TrueTypeFontCache::GetGlyphWidth(), and UniscribeShapeRun().
|
inline |
Get the height of the font.
Definition at line 53 of file fontcache.h.
References height.
Referenced by FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(), GetCharacterHeight(), HFontFromFont(), and UniscribeShapeRun().
|
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 FreeTypeFontCache, CoreTextFontCache, and Win32FontCache.
Definition at line 108 of file fontcache.h.
Referenced by HFontFromFont().
|
inline |
Get the FontSize of the font.
Definition at line 47 of file fontcache.h.
References fs.
Referenced by DrawLayoutLine(), FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(), FallbackParagraphLayout::NextLine(), and UniscribeShapeRun().
|
inline |
Check whether the font cache has a parent.
Definition at line 135 of file fontcache.h.
Referenced by InitFontCache().
|
static |
Definition at line 85 of file fontcache.cpp.
|
pure virtual |
Is this a built-in sprite font?
Implemented in FreeTypeFontCache, SpriteFontCache, TrueTypeFontCache, CoreTextFontCache, and MockFontCache.
Referenced by FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun().
|
pure virtual |
Map a character into a glyph.
key | The character. |
fallback | Allow fallback to the parent font. |
Implemented in FreeTypeFontCache, SpriteFontCache, CoreTextFontCache, Win32FontCache, and MockFontCache.
Referenced by FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(), MissingGlyphSearcher::FindMissingGlyphs(), GetGlyph(), GetGlyphWidth(), FreeTypeFontCache::MapCharToGlyph(), CoreTextFontCache::MapCharToGlyph(), Win32FontCache::MapCharToGlyph(), and UniscribeShapeRun().
|
protected |
The ascender value of the font.
Definition at line 27 of file fontcache.h.
Referenced by SpriteFontCache::ClearFontCache(), GetAscender(), and SpriteFontCache::SpriteFontCache().
|
staticprotected |
All the font caches.
Definition at line 23 of file fontcache.h.
Referenced by FontCache(), Get(), and ~FontCache().
|
static |
Default unscaled font ascenders.
Default unscaled ascenders for the different sizes of fonts.
Definition at line 28 of file fontcache.h.
|
static |
Default unscaled font heights.
Default unscaled heights for the different sizes of fonts.
Definition at line 26 of file fontcache.h.
|
protected |
The descender value of the font.
Definition at line 28 of file fontcache.h.
Referenced by GetDescender().
|
protected |
The size of the font.
Definition at line 25 of file fontcache.h.
Referenced by SpriteFontCache::ClearFontCache(), TrueTypeFontCache::ClearFontCache(), FontCache(), Get(), TrueTypeFontCache::GetDrawGlyphShadow(), SpriteFontCache::GetGlyph(), SpriteFontCache::GetGlyphWidth(), GetName(), GetSize(), SpriteFontCache::MapCharToGlyph(), and ~FontCache().
|
protected |
The height of the font.
Definition at line 26 of file fontcache.h.
Referenced by SpriteFontCache::ClearFontCache(), GetFontSize(), MockFontCache::GetGlyphWidth(), GetHeight(), and SpriteFontCache::SpriteFontCache().
|
protected |
The parent of this font cache.
Definition at line 24 of file fontcache.h.
Referenced by FontCache(), TrueTypeFontCache::GetGlyph(), TrueTypeFontCache::GetGlyphWidth(), FreeTypeFontCache::MapCharToGlyph(), CoreTextFontCache::MapCharToGlyph(), Win32FontCache::MapCharToGlyph(), and ~FontCache().