Skip to content

Commit ef93748

Browse files
committed
client: NUKE bigchars
1 parent 4f1fe1e commit ef93748

File tree

6 files changed

+28
-119
lines changed

6 files changed

+28
-119
lines changed

src.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ endif()
8989
set(MEDIA_EMBED_DIR ${ENGINE_DIR}/media)
9090
set(MEDIA_EMBED_LIST
9191
fonts/unifont.ttf
92-
gfx/2d/bigchars.png
9392
scripts/engine.shader
9493
sound/null.wav
9594
)

src/engine/client/cl_main.cpp

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,35 +2109,41 @@ bool CL_InitRenderer()
21092109
cl_consoleFontSize = Cvar_Get( "cl_consoleFontSize", "16", CVAR_LATCH );
21102110
cl_consoleFontScaling = Cvar_Get( "cl_consoleFontScaling", "1", CVAR_LATCH );
21112111

2112-
// load character sets
2113-
cls.charSetShader = re.RegisterShader( "gfx/2d/bigchars", RSF_2D );
2114-
cls.useLegacyConsoleFont = cls.useLegacyConsoleFace = true;
2115-
21162112
// Register console font specified by cl_consoleFont, if any
21172113
// filehandle is unused but forces FS_FOpenFileRead() to heed purecheck because it does not when filehandle is nullptr
21182114
if ( cl_consoleFont->string[0] )
21192115
{
2120-
if ( FS_FOpenFileRead( cl_consoleFont->string, &f ) >= 0 )
2116+
if ( FS_FOpenFileRead( cl_consoleFont->string, &f ) < 0 )
21212117
{
2122-
if ( cl_consoleFontScaling->value == 0 )
2123-
{
2124-
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer );
2125-
}
2126-
else
2127-
{
2128-
// This gets 12px on 1920×1080 screen, which is libRocket default for 1em
2129-
int fontScale = std::min(cls.windowConfig.vidWidth, cls.windowConfig.vidHeight) / 90;
2118+
Log::Warn("Font file '%s' not found", cl_consoleFont->string);
21302119

2131-
// fontScale / 12px gets 1px on 1920×1080 screen
2132-
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer * fontScale / 12 );
2133-
}
2120+
Cvar::ClearFlags("cl_consoleFont", CVAR_LATCH);
2121+
Cvar_Set( "cl_consoleFont", "fonts/unifont.ttf" );
2122+
Cvar::AddFlags("cl_consoleFont", CVAR_LATCH);
2123+
}
21342124

2135-
if ( cls.consoleFont != nullptr )
2136-
cls.useLegacyConsoleFont = false;
2125+
if ( cl_consoleFontScaling->value == 0 )
2126+
{
2127+
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer );
21372128
}
21382129
else
21392130
{
2140-
Log::Warn("Font file '%s' not found", cl_consoleFont->string);
2131+
// This gets 12px on 1920×1080 screen, which is libRocket default for 1em
2132+
int fontScale = std::min(cls.windowConfig.vidWidth, cls.windowConfig.vidHeight) / 90;
2133+
2134+
// fontScale / 12px gets 1px on 1920×1080 screen
2135+
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer * fontScale / 12 );
2136+
}
2137+
2138+
if ( cls.consoleFont == nullptr )
2139+
{
2140+
// Can this happen?
2141+
cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer );
2142+
2143+
if ( cls.consoleFont == nullptr )
2144+
{
2145+
Sys::Error( "Failed to load font %s", cl_consoleFont->string );
2146+
}
21412147
}
21422148

21432149
FS_FCloseFile( f );

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ struct clientStatic_t
317317
WindowConfig windowConfig;
318318
qhandle_t charSetShader;
319319
qhandle_t whiteShader;
320-
bool useLegacyConsoleFont;
321-
bool useLegacyConsoleFace;
322320
fontInfo_t *consoleFont;
323321

324322
// www downloading
@@ -657,7 +655,6 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h );
657655
void SCR_FillRect( float x, float y, float width, float height, const Color::Color& color );
658656

659657
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 );
661658
void SCR_DrawConsoleFontUnichar( float x, float y, int ch );
662659
float SCR_ConsoleFontCharWidth( const char *s );
663660
float SCR_ConsoleFontUnicharWidth( int ch );
-6.06 KB
Binary file not shown.

src/engine/media/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-
}

0 commit comments

Comments
 (0)