mirror of https://github.com/OpenTTD/OpenTTD
Fix: Don't rely on static initialization to set up sprite font caches.
The order of static initialization is undefined, so this can cause initalization before relevant caches are initializations.pull/10839/head
parent
418888ac23
commit
f454ec8d63
|
@ -65,9 +65,14 @@ int GetCharacterHeight(FontSize size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* static */ FontCache *FontCache::caches[FS_END] = { new SpriteFontCache(FS_NORMAL), new SpriteFontCache(FS_SMALL), new SpriteFontCache(FS_LARGE), new SpriteFontCache(FS_MONO) };
|
/* static */ FontCache *FontCache::caches[FS_END];
|
||||||
|
|
||||||
|
|
||||||
|
/* static */ void FontCache::InitializeFontCaches()
|
||||||
|
{
|
||||||
|
for (FontSize fs = FS_BEGIN; fs != FS_END; fs++) {
|
||||||
|
if (FontCache::caches[fs] == nullptr) new SpriteFontCache(fs); /* FontCache inserts itself into to the cache. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if a glyph should be rendered with anti-aliasing. */
|
/* Check if a glyph should be rendered with anti-aliasing. */
|
||||||
bool GetFontAAState(FontSize size, bool check_blitter)
|
bool GetFontAAState(FontSize size, bool check_blitter)
|
||||||
|
@ -136,6 +141,8 @@ extern void LoadCoreTextFont(FontSize fs);
|
||||||
*/
|
*/
|
||||||
void InitFontCache(bool monospace)
|
void InitFontCache(bool monospace)
|
||||||
{
|
{
|
||||||
|
FontCache::InitializeFontCaches();
|
||||||
|
|
||||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
||||||
if (monospace != (fs == FS_MONO)) continue;
|
if (monospace != (fs == FS_MONO)) continue;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
FontCache(FontSize fs);
|
FontCache(FontSize fs);
|
||||||
virtual ~FontCache();
|
virtual ~FontCache();
|
||||||
|
|
||||||
|
static void InitializeFontCaches();
|
||||||
|
|
||||||
static int GetDefaultFontHeight(FontSize fs);
|
static int GetDefaultFontHeight(FontSize fs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue