Skip to content

Commit

Permalink
[SP] Adjust MenuFontToReal to only try to register fonts once. (#1225)
Browse files Browse the repository at this point in the history
This fixes #1214, which was introduced in d786f19.
  • Loading branch information
Daggolin committed Mar 25, 2024
1 parent 62124e1 commit d2afcfe
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions code/ui/ui_shared.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit d2afcfe

Please sign in to comment.