From 0314d1871e892499dc759b180dc46caf10dcb21a Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sun, 24 Mar 2024 13:42:19 +0100 Subject: [PATCH] [SP] Adjust MenuFontToReal to only try to register fonts once. This fixes #1214, which was introduced in d786f197d1ebb967707f0570c7d5c0f45205c0a5. --- code/ui/ui_shared.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 07461b8adf..f2d5a3cf3b 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -3074,12 +3074,29 @@ qboolean ItemParse_name( itemDef_t *item) int MenuFontToReal( int menuFontIndex ) { + static int fonthandle_aurabesh; + static int fonthandle_ergoec; + static int fonthandle_anewhope; + static int fonthandle_arialnb; + + static qboolean fontsRegistered = qfalse; + + if ( !fontsRegistered ) + { // Only try registering the fonts once + fonthandle_aurabesh = UI_RegisterFont( "aurabesh" ); + fonthandle_ergoec = UI_RegisterFont( "ergoec" ); + fonthandle_anewhope = UI_RegisterFont( "anewhope" ); + fonthandle_arialnb = UI_RegisterFont( "arialnb" ); + + fontsRegistered = qtrue; + } + // Default fonts from a clean installation switch ( menuFontIndex ) { - case 1: return UI_RegisterFont( "aurabesh" ); - case 2: return UI_RegisterFont( "ergoec" ); - case 3: return UI_RegisterFont( "anewhope" ); - case 4: return UI_RegisterFont( "arialnb" ); + case 1: return fonthandle_aurabesh; + case 2: return fonthandle_ergoec; + case 3: return fonthandle_anewhope; + case 4: return fonthandle_arialnb; default: return DC->Assets.qhMediumFont;