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];
67 if ((key & SPRITE_GLYPH) != 0)
return this->
parent->GetGlyphWidth(key);
70 if (glyph ==
nullptr || glyph->
data ==
nullptr) {
72 glyph = this->GetGlyphPtr(key);
80 if ((key & SPRITE_GLYPH) != 0)
return this->
parent->GetGlyph(key);
84 if (glyph !=
nullptr && glyph->
data !=
nullptr)
return glyph->GetSprite();
86 return this->InternalGetGlyph(key, GetFontAAState());
Font cache for basic fonts.
std::unique_ptr< FontCache > parent
The parent of this font cache.
const FontSize fs
The size of the font.
static void ResetFontCache(FontSize size)
Reset cached font information.
~TrueTypeFontCache() override
Free everything that was allocated for this font cache.
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.
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< std::byte[]> data
The loaded sprite.
uint8_t width
The width of the glyph.
Common base definition for font file based font caches.