1
0
Fork 0

Codechange: Add ResizeFont function to the fontcache class.

pull/12690/head
Sadie del Solar 2024-05-12 16:36:05 -07:00
parent 23d1304779
commit 46ebb42fa8
2 changed files with 24 additions and 0 deletions

View File

@ -148,6 +148,29 @@ static void LoadFontHelper(FontSize fs)
#endif #endif
} }
/**
* Called to change the size setting of a font in OpenTTD.
* @param font_size FontSize(enum not pixel size) of the font to change.
* @param size The new pixel size to use for this font.
*/
void ResizeFont(FontSize font_size, uint size)
{
FontCacheSubSetting *setting = GetFontCacheSubSetting(font_size);
if (setting->size == size) return;
setting->size = size;
FontCache *loaded_font = FontCache::Get(font_size);
loaded_font->SetFontSize(size);
LoadStringWidthTable();
UpdateAllVirtCoords();
ReInitAllWindows(true);
if (_save_config) SaveToConfig();
}
void SetFont(FontSize font_size, const std::string &font, uint size) void SetFont(FontSize font_size, const std::string &font, uint size)
{ {
FontCacheSubSetting *setting = GetFontCacheSubSetting(font_size); FontCacheSubSetting *setting = GetFontCacheSubSetting(font_size);

View File

@ -232,6 +232,7 @@ std::string GetFontCacheFontName(FontSize fs);
void DebugPrintFontSettings(const std::string &desc); void DebugPrintFontSettings(const std::string &desc);
bool GetFontAAState(); bool GetFontAAState();
void InitFontCache(); void InitFontCache();
void ResizeFont(FontSize font_size, uint size);
void SetFont(FontSize fontsize, const std::string &font, uint size); void SetFont(FontSize fontsize, const std::string &font, uint size);
void UninitFontCache(); void UninitFontCache();