Skip to content

Commit e2fe98d

Browse files
committed
NUKE legacy console font ('bigchars')
NUKE the legacy console font rendering code, which loaded a shader named gfx/2d/bigchars. And remove the assets. This was only used if the font speicfied by cl_consoleFont failed to load
1 parent 0a8c033 commit e2fe98d

File tree

6 files changed

+29
-116
lines changed

6 files changed

+29
-116
lines changed
-6.06 KB
Binary file not shown.

pkg/daemon_src.dpkdir/scripts/engine.shader

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,3 @@ white
77
rgbgen vertex
88
}
99
}
10-
11-
// console font fallback
12-
gfx/2d/bigchars
13-
{
14-
nopicmip
15-
nomipmaps
16-
{
17-
map gfx/2d/bigchars
18-
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
19-
rgbgen vertex
20-
}
21-
}

src/engine/client/cl_main.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,8 +2095,6 @@ bool CL_InitRenderer()
20952095
return false;
20962096
}
20972097

2098-
fileHandle_t f;
2099-
21002098
// this sets up the renderer and calls R_Init
21012099
if ( !re.BeginRegistration( &cls.windowConfig ) )
21022100
{
@@ -2107,28 +2105,37 @@ bool CL_InitRenderer()
21072105
cl_consoleFontSize = Cvar_Get( "cl_consoleFontSize", "16", CVAR_LATCH );
21082106
cl_consoleFontScaling = Cvar_Get( "cl_consoleFontScaling", "1", CVAR_LATCH );
21092107

2110-
// load character sets
2111-
cls.charSetShader = re.RegisterShader( "gfx/2d/bigchars", RSF_2D );
2112-
cls.useLegacyConsoleFont = cls.useLegacyConsoleFace = true;
2113-
21142108
// Register console font specified by cl_consoleFont. Empty string means use the embbed Unifont
21152109

2116-
if ( cl_consoleFontScaling->value == 0 )
2117-
{
2118-
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer );
2119-
}
2120-
else
2110+
int fontSize = cl_consoleFontSize->integer;
2111+
2112+
if ( cl_consoleFontScaling->integer )
21212113
{
21222114
// This gets 12px on 1920×1080 screen, which is libRocket default for 1em
21232115
int fontScale = std::min(cls.windowConfig.vidWidth, cls.windowConfig.vidHeight) / 90;
21242116

21252117
// fontScale / 12px gets 1px on 1920×1080 screen
2126-
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer * fontScale / 12 );
2118+
fontSize = cl_consoleFontSize->integer * fontScale / 12;
2119+
}
2120+
2121+
if ( cl_consoleFont->string[ 0 ] )
2122+
{
2123+
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, fontSize );
2124+
if ( cls.consoleFont == nullptr )
2125+
{
2126+
Log::Warn( "Couldn't load font file '%s', falling back to default console font",
2127+
cl_consoleFont->string );
2128+
}
21272129
}
21282130

2129-
if ( cls.consoleFont != nullptr )
2131+
if ( cls.consoleFont == nullptr )
21302132
{
2131-
cls.useLegacyConsoleFont = false;
2133+
cls.consoleFont = re.RegisterFont( "", fontSize );
2134+
2135+
if ( cls.consoleFont == nullptr )
2136+
{
2137+
Sys::Error( "Failed to load built-in console font" );
2138+
}
21322139
}
21332140

21342141
cls.whiteShader = re.RegisterShader( "white", RSF_NOMIP );

src/engine/client/cl_scrn.cpp

Lines changed: 3 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ static glyphInfo_t *Glyph( int ch )
107107

108108
void SCR_DrawConsoleFontUnichar( float x, float y, int ch )
109109
{
110-
if ( cls.useLegacyConsoleFont )
111-
{
112-
SCR_DrawSmallUnichar( ( int ) x, ( int ) y, ch );
113-
return;
114-
}
115-
116110
if ( ch != ' ' )
117111
{
118112
glyphInfo_t *glyph = Glyph( ch );
@@ -126,53 +120,6 @@ void SCR_DrawConsoleFontUnichar( float x, float y, int ch )
126120
}
127121
}
128122

129-
/*
130-
** SCR_DrawSmallUnichar
131-
** small chars are drawn at native screen resolution
132-
*/
133-
void SCR_DrawSmallUnichar( int x, int y, int ch )
134-
{
135-
int row, col;
136-
float frow, fcol;
137-
float size;
138-
139-
if ( ch < 0x100 || cls.useLegacyConsoleFont )
140-
{
141-
if ( ch == ' ' ) {
142-
return;
143-
}
144-
145-
if ( y < -SMALLCHAR_HEIGHT ) {
146-
return;
147-
}
148-
149-
if ( ch >= 0x100 ) { ch = 0; }
150-
151-
row = ch>>4;
152-
col = ch&15;
153-
154-
frow = row*0.0625;
155-
fcol = col*0.0625;
156-
size = 0.0625;
157-
158-
// adjust for baseline
159-
re.DrawStretchPic( x, y - (int)( SMALLCHAR_HEIGHT / ( CONSOLE_FONT_VPADDING + 1 ) ),
160-
SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
161-
fcol, frow,
162-
fcol + size, frow + size,
163-
cls.charSetShader );
164-
} else {
165-
glyphInfo_t *glyph = Glyph( ch );
166-
167-
re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, glyph->imageHeight,
168-
glyph->s,
169-
glyph->t,
170-
glyph->s2,
171-
glyph->t2,
172-
glyph->glyph );
173-
}
174-
}
175-
176123
/*
177124
==================
178125
SCR_DrawSmallString[Color]
@@ -335,9 +282,7 @@ void SCR_UpdateScreen()
335282

336283
float SCR_ConsoleFontUnicharWidth( int ch )
337284
{
338-
return cls.useLegacyConsoleFont
339-
? SMALLCHAR_WIDTH
340-
: Glyph( ch )->xSkip + cl_consoleFontKerning->value;
285+
return Glyph( ch )->xSkip + cl_consoleFontKerning->value;
341286
}
342287

343288
float SCR_ConsoleFontCharWidth( const char *s )
@@ -347,44 +292,18 @@ float SCR_ConsoleFontCharWidth( const char *s )
347292

348293
float SCR_ConsoleFontCharHeight()
349294
{
350-
return cls.useLegacyConsoleFont
351-
? SMALLCHAR_HEIGHT
352-
: cls.consoleFont->glyphBlock[0][(unsigned)'I'].imageHeight + CONSOLE_FONT_VPADDING * cl_consoleFontSize->value;
295+
return cls.consoleFont->glyphBlock[0][(unsigned)'I'].imageHeight + CONSOLE_FONT_VPADDING * cl_consoleFontSize->value;
353296
}
354297

355298
float SCR_ConsoleFontCharVPadding()
356299
{
357-
return cls.useLegacyConsoleFont
358-
? 0
359-
: std::max( 0, -cls.consoleFont->glyphBlock[0][(unsigned)'g'].bottom >> 6);
300+
return std::max( 0, -cls.consoleFont->glyphBlock[0][(unsigned)'g'].bottom >> 6);
360301
}
361302

362303
float SCR_ConsoleFontStringWidth( const char* s, int len )
363304
{
364305
float width = 0;
365306

366-
if( cls.useLegacyConsoleFont )
367-
{
368-
if( cls.useLegacyConsoleFace )
369-
{
370-
return len * SMALLCHAR_WIDTH;
371-
}
372-
else
373-
{
374-
int l = 0;
375-
const char *str = s;
376-
377-
while( *str && len > 0 )
378-
{
379-
l++;
380-
str += Q_UTF8_Width( str );
381-
len--;
382-
}
383-
384-
return l * SMALLCHAR_WIDTH;
385-
}
386-
}
387-
388307
while( *s && len > 0 )
389308
{
390309
width += SCR_ConsoleFontCharWidth( s );

src/engine/client/client.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,7 @@ struct clientStatic_t
315315

316316
// rendering info
317317
WindowConfig windowConfig;
318-
qhandle_t charSetShader;
319318
qhandle_t whiteShader;
320-
bool useLegacyConsoleFont;
321-
bool useLegacyConsoleFace;
322319
fontInfo_t *consoleFont;
323320

324321
// www downloading
@@ -655,7 +652,6 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h );
655652
void SCR_FillRect( float x, float y, float width, float height, const Color::Color& color );
656653

657654
void SCR_DrawSmallStringExt( int x, int y, const char *string, const Color::Color& setColor, bool forceColor, bool noColorEscape );
658-
void SCR_DrawSmallUnichar( int x, int y, int ch );
659655
void SCR_DrawConsoleFontUnichar( float x, float y, int ch );
660656
float SCR_ConsoleFontCharWidth( const char *s );
661657
float SCR_ConsoleFontUnicharWidth( int ch );

src/engine/null/null_renderer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ qhandle_t RE_RegisterShader( const char *, int )
5252
}
5353
fontInfo_t* RE_RegisterFont( const char *, int )
5454
{
55-
return nullptr;
55+
return new fontInfo_t{};
56+
}
57+
void RE_UnregisterFont( fontInfo_t* p )
58+
{
59+
delete p;
5660
}
5761
void RE_GlyphChar( fontInfo_t *, int, glyphInfo_t *glyph )
5862
{
@@ -70,7 +74,6 @@ void RE_GlyphChar( fontInfo_t *, int, glyphInfo_t *glyph )
7074
glyph->glyph = 1;
7175
glyph->shaderName[0] = '\0';
7276
}
73-
void RE_UnregisterFont( fontInfo_t* ) { }
7477
void RE_LoadWorldMap( const char * ) { }
7578
void RE_SetWorldVisData( const byte * ) { }
7679
void RE_EndRegistration() { }

0 commit comments

Comments
 (0)