39 auto fc = provider->LoadFont(fs, fonttype);
40 if (fc !=
nullptr)
return fc;
58 [&](
auto *provider) {
return provider->FindFallbackFont(
settings, language_isocode, callback); });
61int FontCache::GetDefaultFontHeight(
FontSize fs)
115void SetFont(
FontSize fontsize,
const std::string &font, uint size)
118 bool changed =
false;
120 if (setting->
font != font) {
121 setting->
font = font;
125 if (setting->
size != size) {
126 setting->
size = size;
130 if (!changed)
return;
136 if (fs == fontsize)
continue;
141 _fcsettings = std::move(backup);
170 return IsDefaultFont(setting) ? FontCache::GetDefaultFontHeight(fs) : setting.
size;
173#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
182 case FS_NORMAL:
return "OpenTTD-Sans.ttf";
183 case FS_SMALL:
return "OpenTTD-Small.ttf";
184 case FS_LARGE:
return "OpenTTD-Serif.ttf";
185 case FS_MONO:
return "OpenTTD-Mono.ttf";
186 default: NOT_REACHED();
198#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
225 if (fc ==
nullptr)
return;
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
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.
bool HasParent()
Check whether the font cache has a parent.
std::unique_ptr< FontCache > parent
The parent of this font cache.
static std::array< std::unique_ptr< FontCache >, FS_END > caches
All the font caches.
static void ClearFontCaches(FontSizes fontsizes)
Clear cached information for the specified font caches.
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.
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.
static FontCache * Get(FontSize fs)
Get the font cache of a given font size.
static void InitializeFontCaches()
Initialise font caches with the base sprite font cache for all sizes.
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.
static void ResetFontCache(FontSize size)
Reset cached font information.
A searcher for missing glyphs.
static std::vector< FontCacheFactory * > & GetProviders()
Get the currently known providers.
Factory to 'query' all available blitters.
std::string FioFindFullPath(Subdirectory subdir, std::string_view filename)
Find a path to the filename in one of the search directories.
Functions for Standard In/Out file operations.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
fluid_settings_t * settings
FluidSynth settings handle.
static std::string GetDefaultTruetypeFontFile(FontSize fs)
Get path of default font file for a given font size.
uint GetFontCacheFontSize(FontSize fs)
Get the scalable font size to use for a FontSize.
static bool IsDefaultFont(const FontCacheSubSetting &setting)
Test if a font setting uses the default font.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
std::string GetFontCacheFontName(FontSize fs)
Get font to use for a given font size.
static std::string GetDefaultTruetypeFont(FontSize fs)
Get name of default font file for a given font size.
Functions to read fonts from files and cache them.
FontType
Different types of font that can be loaded.
@ TrueType
Scalable TrueType fonts.
@ Sprite
Bitmap sprites from GRF files.
FontCacheSubSetting * GetFontCacheSubSetting(FontSize fs)
Get the settings of a given font size.
void LoadStringWidthTable(FontSizes fontsizes)
Initialize _stringwidth_table cache for the specified font sizes.
Functions related to laying out the texts.
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.
A number of safeguards to prevent using unsafe methods.
void SaveToConfig()
Save the values to the configuration file.
Functions related to setting/changing the settings.
Definition of base types and functions in a cross-platform compatible way.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
Functions related to OTTD's strings.
Settings for the four different fonts.
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
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.
Functions related to (drawing on) viewports.
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Window functions not directly related to making/drawing windows.