18static const GlyphID SPRITE_GLYPH = 1U << 30;
34 static void InitializeFontCaches();
142 return this->parent !=
nullptr;
165inline void ClearFontCache()
186inline bool GetDrawGlyphShadow(
FontSize size)
219 default: NOT_REACHED();
232bool GetFontAAState();
233void SetFont(
FontSize fontsize,
const std::string &font, uint size);
Font cache for basic fonts.
virtual std::string GetFontName()=0
Get the name of this font.
int GetHeight() const
Get the height of the font.
virtual void ClearFontCache()=0
Clear the font cache.
int height
The height of the font.
FontCache * parent
The parent of this font cache.
bool HasParent()
Check whether the font cache has a parent.
virtual int GetFontSize() const
Get the nominal font size of the font.
virtual const void * GetOSHandle()
Get the native OS font handle, if there is one.
virtual GlyphID MapCharToGlyph(char32_t key, bool fallback=true)=0
Map a character into a glyph.
virtual bool IsBuiltInFont()=0
Is this a built-in sprite font?
static FontCache * caches[FS_END]
All the font caches.
virtual const Sprite * GetGlyph(GlyphID key)=0
Get the glyph (sprite) of the given key.
virtual void InitializeUnicodeGlyphMap()=0
Initialize the glyph map.
virtual uint GetGlyphWidth(GlyphID key)=0
Get the width of the glyph with the given key.
virtual ~FontCache()
Clean everything up.
const FontSize fs
The size of the font.
static std::string GetName(FontSize fs)
Get the font name of a given font size.
int GetAscender() const
Get the ascender value of the font.
int descender
The descender value of the font.
static FontCache * Get(FontSize fs)
Get the font cache of a given font size.
FontSize GetSize() const
Get the FontSize of the font.
int GetDescender() const
Get the descender value of the font.
virtual bool GetDrawGlyphShadow()=0
Do we need to draw a glyph shadow?
int ascender
The ascender value of the font.
virtual void SetUnicodeGlyph(char32_t key, SpriteID sprite)=0
Map a SpriteID to the key.
void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite)
Map a SpriteID to the font size and key.
void InitFontCache(bool monospace)
(Re)initialize the font cache related things, i.e.
const Sprite * GetGlyph(FontSize size, char32_t key)
Get the Sprite for a glyph.
void UninitFontCache()
Free everything allocated w.r.t.
uint GetGlyphWidth(FontSize size, char32_t key)
Get the width of a glyph.
void InitializeUnicodeGlyphMap()
Initialize the glyph map.
uint GetFontCacheFontSize(FontSize fs)
Get the scalable font size to use for a FontSize.
FontCacheSubSetting * GetFontCacheSubSetting(FontSize fs)
Get the settings of a given font size.
std::string GetFontCacheFontName(FontSize fs)
Get font to use for a given font size.
uint32_t GlyphID
Glyphs are characters from a font.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
FontSize
Available font sizes.
@ FS_MONO
Index of the monospaced font in the font tables.
@ FS_SMALL
Index of the small font in the font tables.
@ FS_NORMAL
Index of the normal font in the font tables.
@ FS_LARGE
Index of the large font in the font tables.
Functions to cache sprites in memory.
Settings for the four different fonts.
FontCacheSubSetting large
The largest font; mostly used for newspapers.
FontCacheSubSetting mono
The mono space font used for license/readme viewers.
FontCacheSubSetting medium
The normal font size.
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
FontCacheSubSetting small
The smallest font; mostly used for zoomed out view.
bool global_aa
Whether to anti alias all font sizes.
Settings for a single font.
std::string font
The name of the font, or path to the font.
uint size
The (requested) size of the font.
const void * os_handle
Optional native OS font info. Only valid during font search.
Data structure describing a sprite.