Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SP] Adjust MenuFontToReal to only try to register fonts once. #1225

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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