mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-12 16:21:04 +02:00
Using idTech 5 fonts for gui and console.
This commit is contained in:
@@ -388,11 +388,47 @@ idRenderSystemLocal::DrawSmallChar
|
||||
small chars are drawn at native screen resolution
|
||||
=====================
|
||||
*/
|
||||
void idRenderSystemLocal::DrawSmallChar( int x, int y, int ch, const idMaterial *material ) {
|
||||
int row, col;
|
||||
float frow, fcol;
|
||||
float size;
|
||||
static const char *CONSOLE_FONT_NAME = "editor";
|
||||
|
||||
static void R_DrawFontChar( idRenderSystemLocal *renderSystem, float x, float y, float scale, float baselineOffset, int ch ) {
|
||||
idFont *font = renderSystem->RegisterFont( CONSOLE_FONT_NAME );
|
||||
if ( font == NULL || ch == ' ' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
scaledGlyphInfo_t glyphInfo;
|
||||
font->GetScaledGlyph( scale, ch & 255, glyphInfo );
|
||||
if ( glyphInfo.material == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
float baseline = y + baselineOffset;
|
||||
renderSystem->DrawStretchPic( x + glyphInfo.left, baseline - glyphInfo.top,
|
||||
glyphInfo.width, glyphInfo.height,
|
||||
glyphInfo.s1, glyphInfo.t1, glyphInfo.s2, glyphInfo.t2,
|
||||
glyphInfo.material );
|
||||
}
|
||||
|
||||
static const float CONSOLE_SMALL_FONT_SCALE = 0.255f;
|
||||
static const float CONSOLE_SMALL_CHAR_PAD = 0.75f;
|
||||
static const float CONSOLE_BIG_FONT_SCALE = 0.33f;
|
||||
static const float CONSOLE_BIG_CHAR_PAD = 0.75f;
|
||||
|
||||
static float R_FontGlyphAdvance( idRenderSystemLocal *renderSystem, float scale, int ch ) {
|
||||
idFont *font = renderSystem->RegisterFont( CONSOLE_FONT_NAME );
|
||||
if ( font == NULL ) {
|
||||
return SMALLCHAR_WIDTH;
|
||||
}
|
||||
|
||||
float advance = font->GetGlyphWidth( scale, ch & 255 );
|
||||
if ( advance <= 0.0f ) {
|
||||
advance = SMALLCHAR_WIDTH;
|
||||
}
|
||||
return advance;
|
||||
}
|
||||
|
||||
void idRenderSystemLocal::DrawSmallChar( int x, int y, int ch, const idMaterial *material ) {
|
||||
(void)material;
|
||||
ch &= 255;
|
||||
|
||||
if ( ch == ' ' ) {
|
||||
@@ -403,17 +439,7 @@ void idRenderSystemLocal::DrawSmallChar( int x, int y, int ch, const idMaterial
|
||||
return;
|
||||
}
|
||||
|
||||
row = ch >> 4;
|
||||
col = ch & 15;
|
||||
|
||||
frow = row * 0.0625f;
|
||||
fcol = col * 0.0625f;
|
||||
size = 0.0625f;
|
||||
|
||||
DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT,
|
||||
fcol, frow,
|
||||
fcol + size, frow + size,
|
||||
material );
|
||||
R_DrawFontChar( this, x, y, CONSOLE_SMALL_FONT_SCALE, SMALLCHAR_HEIGHT - 2.0f, ch );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -450,7 +476,7 @@ void idRenderSystemLocal::DrawSmallStringExt( int x, int y, const char *string,
|
||||
continue;
|
||||
}
|
||||
DrawSmallChar( xx, y, *s, material );
|
||||
xx += SMALLCHAR_WIDTH;
|
||||
xx += idMath::FtoiFast( R_FontGlyphAdvance( this, CONSOLE_SMALL_FONT_SCALE, *s ) + CONSOLE_SMALL_CHAR_PAD );
|
||||
s++;
|
||||
}
|
||||
SetColor( colorWhite );
|
||||
@@ -462,10 +488,7 @@ idRenderSystemLocal::DrawBigChar
|
||||
=====================
|
||||
*/
|
||||
void idRenderSystemLocal::DrawBigChar( int x, int y, int ch, const idMaterial *material ) {
|
||||
int row, col;
|
||||
float frow, fcol;
|
||||
float size;
|
||||
|
||||
(void)material;
|
||||
ch &= 255;
|
||||
|
||||
if ( ch == ' ' ) {
|
||||
@@ -476,17 +499,7 @@ void idRenderSystemLocal::DrawBigChar( int x, int y, int ch, const idMaterial *m
|
||||
return;
|
||||
}
|
||||
|
||||
row = ch >> 4;
|
||||
col = ch & 15;
|
||||
|
||||
frow = row * 0.0625f;
|
||||
fcol = col * 0.0625f;
|
||||
size = 0.0625f;
|
||||
|
||||
DrawStretchPic( x, y, BIGCHAR_WIDTH, BIGCHAR_HEIGHT,
|
||||
fcol, frow,
|
||||
fcol + size, frow + size,
|
||||
material );
|
||||
R_DrawFontChar( this, x, y, CONSOLE_BIG_FONT_SCALE, BIGCHAR_HEIGHT - 1.0f, ch );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -523,7 +536,7 @@ void idRenderSystemLocal::DrawBigStringExt( int x, int y, const char *string, co
|
||||
continue;
|
||||
}
|
||||
DrawBigChar( xx, y, *s, material );
|
||||
xx += BIGCHAR_WIDTH;
|
||||
xx += idMath::FtoiFast( R_FontGlyphAdvance( this, CONSOLE_BIG_FONT_SCALE, *s ) + CONSOLE_BIG_CHAR_PAD );
|
||||
s++;
|
||||
}
|
||||
SetColor( colorWhite );
|
||||
|
||||
Reference in New Issue
Block a user