OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
12 #include "../fontcache.h"
13 #include "../core/bitmath_func.hpp"
14 #include "../gfx_layout.h"
17 #include "../safeguards.h"
42 this->glyph_to_sprite_map.clear();
49 auto found = this->glyph_to_sprite_map.find(key);
50 if (found == std::end(this->glyph_to_sprite_map))
return nullptr;
51 return &found->second;
56 this->glyph_to_sprite_map[key] = std::move(glyph);
57 return this->glyph_to_sprite_map[key];
70 if (glyph ==
nullptr || glyph->
data ==
nullptr) {
72 glyph = this->GetGlyphPtr(key);
84 if (glyph !=
nullptr && glyph->
data !=
nullptr)
return glyph->GetSprite();
86 return this->InternalGetGlyph(key, GetFontAAState());
virtual ~TrueTypeFontCache()
Free everything that was allocated for this font cache.
Container for information about a glyph.
static void ResetFontCache(FontSize size)
Reset cached font information.
uint GetGlyphWidth(GlyphID key) override
Get the width of the glyph with the given key.
bool GetDrawGlyphShadow() override
Do we need to draw a glyph shadow?
std::unique_ptr< uint8_t[]> data
The loaded sprite.
@ FS_NORMAL
Index of the normal font in the font tables.
uint32_t GlyphID
Glyphs are characters from a font.
const FontSize fs
The size of the font.
virtual uint GetGlyphWidth(GlyphID key)=0
Get the width of the glyph with the given key.
uint8_t width
The width of the glyph.
Font cache for basic fonts.
virtual const Sprite * GetGlyph(GlyphID key)=0
Get the glyph (sprite) of the given key.
FontCache * parent
The parent of this font cache.
void ClearFontCache() override
Reset cached glyphs.
TrueTypeFontCache(FontSize fs, int pixels)
Create a new TrueTypeFontCache.
FontSize
Available font sizes.
const Sprite * GetGlyph(GlyphID key) override
Get the glyph (sprite) of the given key.
Data structure describing a sprite.