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());
Font cache for basic fonts.
FontCache * parent
The parent of this 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.
const FontSize fs
The size of the font.
static void ResetFontCache(FontSize size)
Reset cached font information.
uint GetGlyphWidth(GlyphID key) override
Get the width of the glyph with the given key.
const Sprite * GetGlyph(GlyphID key) override
Get the glyph (sprite) of the given key.
bool GetDrawGlyphShadow() override
Do we need to draw a glyph shadow?
void ClearFontCache() override
Reset cached glyphs.
virtual ~TrueTypeFontCache()
Free everything that was allocated for this font cache.
TrueTypeFontCache(FontSize fs, int pixels)
Create a new TrueTypeFontCache.
uint32_t GlyphID
Glyphs are characters from a font.
FontSize
Available font sizes.
@ FS_NORMAL
Index of the normal font in the font tables.
Data structure describing a sprite.
Container for information about a glyph.
std::unique_ptr< uint8_t[]> data
The loaded sprite.
uint8_t width
The width of the glyph.
Common base definition for font file based font caches.