19static const GlyphID SPRITE_GLYPH = 1U << 30;
24 static std::array<std::unique_ptr<FontCache>, FS_END>
caches;
32 static void Register(std::unique_ptr<FontCache> &&fc);
143 return this->parent !=
nullptr;
166inline bool GetDrawGlyphShadow(
FontSize size)
199 default: NOT_REACHED();
210bool GetFontAAState();
211void SetFont(
FontSize fontsize,
const std::string &font, uint size);
232 virtual std::unique_ptr<FontCache> LoadFont(
FontSize fs,
FontType fonttype) = 0;
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.
static void UninitializeFontCaches()
Free everything allocated w.r.t.
int height
The height of the font.
bool HasParent()
Check whether the font cache has a parent.
virtual int GetFontSize() const
Get the nominal font size of the font.
std::unique_ptr< FontCache > parent
The parent of this font cache.
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.
static std::array< std::unique_ptr< FontCache >, FS_END > caches
All the font caches.
virtual bool IsBuiltInFont()=0
Is this a built-in sprite font?
virtual const Sprite * GetGlyph(GlyphID key)=0
Get the glyph (sprite) of the given key.
static void ClearFontCaches(FontSizes fontsizes)
Clear cached information for the specified font caches.
virtual uint GetGlyphWidth(GlyphID key)=0
Get the width of the glyph with the given key.
static void Register(std::unique_ptr< FontCache > &&fc)
Register a FontCache for its font size.
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.
static const int DEFAULT_FONT_ASCENDER[FS_END]
Default unscaled font ascenders.
static const int DEFAULT_FONT_HEIGHT[FS_END]
Default unscaled font heights.
static void LoadFontCaches(FontSizes fontsizes)
(Re)initialize the font cache related things, i.e.
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?
static void InitializeFontCaches()
Initialise font caches with the base sprite font cache for all sizes.
int ascender
The ascender value of the font.
static std::unique_ptr< FontCache > LoadFont(FontSize fs, FontType fonttype)
Try loading a font with any fontcache factory.
static bool FindFallbackFont(FontCacheSettings *settings, const std::string &language_isocode, MissingGlyphSearcher *callback)
We would like to have a fallback font as the current one doesn't contain all characters we need.
A searcher for missing glyphs.
The ProviderManager manages a single Provider-type.
fluid_settings_t * settings
FluidSynth settings handle.
void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite)
Set the SpriteID for a unicode character.
const Sprite * GetGlyph(FontSize size, char32_t key)
Get the Sprite for a glyph.
FontType
Different types of font that can be loaded.
@ TrueType
Scalable TrueType fonts.
@ Sprite
Bitmap sprites from GRF files.
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.
Definition of the ProviderManager.
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.