/* * CG_ScoreboardFont */ struct qfontface_s *CG_ScoreboardFont( cvar_t *familyCvar, cvar_t *sizeCvar ) { struct qfontface_s *font; font = trap_SCR_RegisterFont( familyCvar->string, QFONT_STYLE_NONE, ceilf( sizeCvar->integer * ( (float)cgs.vidHeight / 600.0f ) ) ); if( !font ) { CG_Printf( "%sWarning: Invalid font in '%s'. Reseting to default\n", familyCvar->name, S_COLOR_YELLOW ); trap_Cvar_Set( familyCvar->name, familyCvar->dvalue ); trap_Cvar_Set( sizeCvar->name, sizeCvar->dvalue ); font = trap_SCR_RegisterFont( familyCvar->string, QFONT_STYLE_NONE, sizeCvar->integer ); if( !font ) font = sizeCvar->integer > DEFAULT_SCOREBOARD_FONT_SIZE ? cgs.fontSystemBig : cgs.fontSystemSmall; } return font; }
/* * CG_RegisterFonts */ void CG_RegisterFonts( void ) { cvar_t *con_fontSystemFamily = trap_Cvar_Get( "con_fontSystemFamily", DEFAULT_SYSTEM_FONT_FAMILY, CVAR_ARCHIVE ); cvar_t *con_fontSystemSmallSize = trap_Cvar_Get( "con_fontSystemSmallSize", STR_TOSTR( DEFAULT_SYSTEM_FONT_SMALL_SIZE ), CVAR_ARCHIVE ); cvar_t *con_fontSystemMediumSize = trap_Cvar_Get( "con_fontSystemMediumSize", STR_TOSTR( DEFAULT_SYSTEM_FONT_MEDIUM_SIZE ), CVAR_ARCHIVE ); cvar_t *con_fontSystemBigSize = trap_Cvar_Get( "con_fontSystemBigSize", STR_TOSTR( DEFAULT_SYSTEM_FONT_BIG_SIZE ), CVAR_ARCHIVE ); // register system fonts Q_strncpyz( cgs.fontSystemFamily, con_fontSystemFamily->string, sizeof( cgs.fontSystemFamily ) ); if( !con_fontSystemSmallSize->integer ) { trap_Cvar_Set( con_fontSystemSmallSize->name, con_fontSystemSmallSize->dvalue ); } if( !con_fontSystemMediumSize->integer ) { trap_Cvar_Set( con_fontSystemMediumSize->name, con_fontSystemMediumSize->dvalue ); } if( !con_fontSystemBigSize->integer ) { trap_Cvar_Set( con_fontSystemBigSize->name, con_fontSystemBigSize->dvalue ); } float scale = cgs.vidHeight / 600.0f; if( scale < 0.4f ) scale = 0.4f; cgs.fontSystemSmallSize = ceilf( con_fontSystemSmallSize->integer * scale ); cgs.fontSystemSmall = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemSmallSize ); if( !cgs.fontSystemSmall ) { Q_strncpyz( cgs.fontSystemFamily, DEFAULT_SYSTEM_FONT_FAMILY, sizeof( cgs.fontSystemFamily ) ); cgs.fontSystemSmallSize = ceilf( DEFAULT_SYSTEM_FONT_SMALL_SIZE * scale ); cgs.fontSystemSmall = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemSmallSize ); if( !cgs.fontSystemSmall ) CG_Error( "Couldn't load default font \"%s\"", cgs.fontSystemFamily ); } cgs.fontSystemMediumSize = ceilf( con_fontSystemMediumSize->integer * scale ); cgs.fontSystemMedium = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemMediumSize ); if( !cgs.fontSystemMedium ) { cgs.fontSystemMediumSize = ceilf( DEFAULT_SYSTEM_FONT_MEDIUM_SIZE * scale ); cgs.fontSystemMedium = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemMediumSize ); } cgs.fontSystemBigSize = ceilf( con_fontSystemBigSize->integer * scale ); cgs.fontSystemBig = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemBigSize ); if( !cgs.fontSystemBig ) { cgs.fontSystemBigSize = ceilf( DEFAULT_SYSTEM_FONT_BIG_SIZE * scale ); cgs.fontSystemBig = trap_SCR_RegisterFont( cgs.fontSystemFamily, QFONT_STYLE_NONE, cgs.fontSystemBigSize ); } }
/* * UI_RegisterFonts */ static void UI_RegisterFonts( void ) { cvar_t *con_fontSystemSmall = trap_Cvar_Get( "con_fontSystemSmall", DEFAULT_FONT_SMALL, CVAR_ARCHIVE ); cvar_t *con_fontSystemMedium = trap_Cvar_Get( "con_fontSystemMedium", DEFAULT_FONT_MEDIUM, CVAR_ARCHIVE ); cvar_t *con_fontSystemBig = trap_Cvar_Get( "con_fontSystemBig", DEFAULT_FONT_BIG, CVAR_ARCHIVE ); uis.fontSystemSmall = trap_SCR_RegisterFont( con_fontSystemSmall->string ); if( !uis.fontSystemSmall ) { uis.fontSystemSmall = trap_SCR_RegisterFont( DEFAULT_FONT_SMALL ); if( !uis.fontSystemSmall ) UI_Error( "Couldn't load default font \"%s\"", DEFAULT_FONT_SMALL ); } uis.fontSystemMedium = trap_SCR_RegisterFont( con_fontSystemMedium->string ); if( !uis.fontSystemMedium ) uis.fontSystemMedium = trap_SCR_RegisterFont( DEFAULT_FONT_MEDIUM ); uis.fontSystemBig = trap_SCR_RegisterFont( con_fontSystemBig->string ); if( !uis.fontSystemBig ) uis.fontSystemBig = trap_SCR_RegisterFont( DEFAULT_FONT_BIG ); }