1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-18 18:02:37 +01:00

Codechange: Move fallback font detection to FontCacheFactory.

Provides a standard interface instead of relying on defines.
This commit is contained in:
Peter Nelson
2025-08-07 18:13:36 +01:00
committed by Peter Nelson
parent 140f2b291a
commit e1a50abcbb
13 changed files with 184 additions and 177 deletions

View File

@@ -9,7 +9,6 @@
#include "stdafx.h"
#include "fontcache.h"
#include "fontdetection.h"
#include "blitter/factory.hpp"
#include "gfx_layout.h"
#include "openttd.h"
@@ -44,6 +43,21 @@ FontCacheSettings _fcsettings;
return nullptr;
}
/**
* We would like to have a fallback font as the current one
* doesn't contain all characters we need.
* This function must set all fonts of settings.
* @param settings the settings to overwrite the fontname of.
* @param language_isocode the language, e.g. en_GB.
* @param callback The function to call to check for missing glyphs.
* @return true if a font has been set, false otherwise.
*/
/* static */ bool FontProviderManager::FindFallbackFont(FontCacheSettings *settings, const std::string &language_isocode, MissingGlyphSearcher *callback)
{
return std::ranges::any_of(FontProviderManager::GetProviders(),
[&](auto *provider) { return provider->FindFallbackFont(settings, language_isocode, callback); });
}
int FontCache::GetDefaultFontHeight(FontSize fs)
{
return FontCache::DEFAULT_FONT_HEIGHT[fs];
@@ -256,8 +270,3 @@ std::string GetFontCacheFontName(FontSize fs)
fc.reset();
}
}
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA)
bool SetFallbackFont(FontCacheSettings *, const std::string &, MissingGlyphSearcher *) { return false; }
#endif /* !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA) */