OpenTTD Source 20250824-master-g98090fe948
|
Functions to read fonts from files and cache them. More...
Go to the source code of this file.
Data Structures | |
class | FontCache |
Font cache for basic fonts. More... | |
struct | FontCacheSubSetting |
Settings for a single font. More... | |
struct | FontCacheSettings |
Settings for the four different fonts. More... | |
class | FontCacheFactory |
Factory for FontCaches. More... | |
class | FontProviderManager |
Typedefs | |
typedef uint32_t | GlyphID |
Glyphs are characters from a font. | |
Enumerations | |
enum class | FontType : uint8_t { Sprite , TrueType } |
Different types of font that can be loaded. More... | |
Functions | |
const Sprite * | GetGlyph (FontSize size, char32_t key) |
Get the Sprite for a glyph. | |
uint | GetGlyphWidth (FontSize size, char32_t key) |
Get the width of a glyph. | |
bool | GetDrawGlyphShadow (FontSize size) |
FontCacheSubSetting * | GetFontCacheSubSetting (FontSize fs) |
Get the settings of a given font size. | |
uint | GetFontCacheFontSize (FontSize fs) |
Get the scalable font size to use for a FontSize. | |
std::string | GetFontCacheFontName (FontSize fs) |
Get font to use for a given font size. | |
bool | GetFontAAState () |
void | SetFont (FontSize fontsize, const std::string &font, uint size) |
void | InitializeUnicodeGlyphMap () |
Initialize the glyph map. | |
void | SetUnicodeGlyph (FontSize size, char32_t key, SpriteID sprite) |
Set the SpriteID for a unicode character. | |
Variables | |
static const GlyphID | SPRITE_GLYPH = 1U << 30 |
FontCacheSettings | _fcsettings |
Functions to read fonts from files and cache them.
Definition in file fontcache.h.
typedef uint32_t GlyphID |
Glyphs are characters from a font.
Definition at line 18 of file fontcache.h.
|
strong |
Different types of font that can be loaded.
Enumerator | |
---|---|
Sprite | Bitmap sprites from GRF files. |
TrueType | Scalable TrueType fonts. |
Definition at line 214 of file fontcache.h.
|
inline |
Definition at line 166 of file fontcache.h.
bool GetFontAAState | ( | ) |
Definition at line 107 of file fontcache.cpp.
std::string GetFontCacheFontName | ( | FontSize | fs | ) |
Get font to use for a given font size.
fs | Font size. |
Definition at line 211 of file fontcache.cpp.
References GetDefaultTruetypeFontFile(), GetFontCacheSubSetting(), FontCacheSettings::prefer_sprite, and settings.
Referenced by FreeTypeFontCacheFactory::LoadFont(), CoreTextFontCacheFactory::LoadFont(), and Win32FontCacheFactory::LoadFont().
uint GetFontCacheFontSize | ( | FontSize | fs | ) |
Get the scalable font size to use for a FontSize.
fs | FontSize to get the scalable font size for. |
Definition at line 167 of file fontcache.cpp.
References GetFontCacheSubSetting(), IsDefaultFont(), and FontCacheSubSetting::size.
Referenced by FreeTypeFontCacheFactory::LoadFont(), CoreTextFontCacheFactory::LoadFont(), and Win32FontCacheFactory::LoadFont().
|
inline |
Get the settings of a given font size.
fs | The font size to look up. |
Definition at line 196 of file fontcache.h.
References FS_LARGE, FS_MONO, FS_NORMAL, FS_SMALL, FontCacheSettings::large, FontCacheSettings::medium, FontCacheSettings::mono, and FontCacheSettings::small.
Referenced by GetFontCacheFontName(), GetFontCacheFontSize(), FreeTypeFontCacheFactory::LoadFont(), CoreTextFontCacheFactory::LoadFont(), and Win32FontCacheFactory::LoadFont().
Get the Sprite for a glyph.
Definition at line 153 of file fontcache.h.
References FontCache::Get(), FontCache::GetGlyph(), and FontCache::MapCharToGlyph().
Referenced by DrawCharCentered().
|
inline |
Get the width of a glyph.
Definition at line 160 of file fontcache.h.
References FontCache::Get(), FontCache::GetGlyphWidth(), and FontCache::MapCharToGlyph().
Referenced by GetCharacterWidth(), LoadStringWidthTable(), and SpriteFontGetWidth().
void InitializeUnicodeGlyphMap | ( | ) |
Initialize the glyph map.
Definition at line 104 of file spritefontcache.cpp.
References FS_BEGIN, and InitializeUnicodeGlyphMap().
Referenced by HandleBootstrap(), InitializeUnicodeGlyphMap(), and LoadSpriteTables().
void SetFont | ( | FontSize | fontsize, |
const std::string & | font, | ||
uint | size | ||
) |
Definition at line 115 of file fontcache.cpp.
Set the SpriteID for a unicode character.
fs | Font size to set. |
key | Unicode character to set. |
sprite | SpriteID of character. |
Definition at line 55 of file spritefontcache.cpp.
References _char_maps.
Referenced by InitializeUnicodeGlyphMap(), and LoadFontGlyph().
|
extern |
Definition at line 28 of file fontcache.cpp.
|
static |
Definition at line 19 of file fontcache.h.