Skip to content

Commit 5e3bb34

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 6d7ab7d commit 5e3bb34

File tree

5 files changed

+24
-114
lines changed

5 files changed

+24
-114
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
@@ -2096,8 +2096,6 @@ bool CL_InitRenderer()
20962096
return false;
20972097
}
20982098

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

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

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

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

2130-
if ( cls.consoleFont != nullptr )
2132+
if ( cls.consoleFont == nullptr )
21312133
{
2132-
cls.useLegacyConsoleFont = false;
2134+
cls.consoleFont = re.RegisterFont( "", fontSize );
2135+
2136+
if ( cls.consoleFont == nullptr )
2137+
{
2138+
Sys::Error( "Failed to load built-in console font" );
2139+
}
21332140
}
21342141

21352142
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
@@ -657,7 +654,6 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h );
657654
void SCR_FillRect( float x, float y, float width, float height, const Color::Color& color );
658655

659656
void SCR_DrawSmallStringExt( int x, int y, const char *string, const Color::Color& setColor, bool forceColor, bool noColorEscape );
660-
void SCR_DrawSmallUnichar( int x, int y, int ch );
661657
void SCR_DrawConsoleFontUnichar( float x, float y, int ch );
662658
float SCR_ConsoleFontCharWidth( const char *s );
663659
float SCR_ConsoleFontUnicharWidth( int ch );

0 commit comments

Comments
 (0)