From f95b6df1282b978a21b2d39cef5dace2f31e017d Mon Sep 17 00:00:00 2001 From: spherallic Date: Wed, 2 Nov 2022 01:26:28 +0100 Subject: [PATCH] Use V_FontStringWidth for name tag width, add kerning value to name tag --- src/hu_stuff.c | 2 +- src/v_video.c | 23 +---------------------- src/v_video.h | 2 +- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 95d06969f..34035fd47 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -236,7 +236,7 @@ void HU_LoadGraphics(void) HU_SetFontProperties(&tny_font, 0, 2, 12); HU_SetFontProperties(&cred_font, 0, 16, 16); HU_SetFontProperties(<_font, 0, 16, 20); - HU_SetFontProperties(&ntb_font, 0, 4, 21); + HU_SetFontProperties(&ntb_font, 2, 4, 21); HU_SetFontProperties(&nto_font, 0, 4, 21); //cache numbers too! diff --git a/src/v_video.c b/src/v_video.c index 5d308d92e..75e5a38ed 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2393,7 +2393,7 @@ static void V_DrawNameTagLine(INT32 x, INT32 y, INT32 option, fixed_t scale, UIN continue; } - w = FixedMul(((ntb_font.chars[c]->width)+2 * dupx) * FRACUNIT, scale); + w = FixedMul(((ntb_font.chars[c]->width)+ntb_font.kerning * dupx) * FRACUNIT, scale); if (FixedInt(cx) > scrwidth) continue; @@ -2519,27 +2519,6 @@ INT32 V_CountNameTagLines(const char *string) return ntlines; } -INT32 V_NameTagWidth(const char *string) -{ - INT32 c, w = 0; - size_t i; - - // It's possible for string to be a null pointer - if (!string) - return 0; - - for (i = 0; i < strlen(string); i++) - { - c = toupper(string[i]) - FONTSTART; - if (c < 0 || c >= FONTSIZE || !ntb_font.chars[c] || !nto_font.chars[c]) - w += ntb_font.spacewidth; - else - w += (ntb_font.chars[c]->width)+2; - } - - return w; -} - // Find string width from supplied font characters & character width. // INT32 V_FontStringWidth(const char *string, INT32 option, fontdef_t font) diff --git a/src/v_video.h b/src/v_video.h index ea96b76a9..b454da748 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -261,7 +261,6 @@ INT16 V_LevelActNumWidth(UINT8 num); // act number width // Draw a string using the nt_font void V_DrawNameTag(INT32 x, INT32 y, INT32 option, fixed_t scale, UINT8 *basecolormap, UINT8 *outlinecolormap, const char *string); INT32 V_CountNameTagLines(const char *string); -INT32 V_NameTagWidth(const char *string); // Find string width or height from supplied font chars INT32 V_FontStringWidth(const char *string, INT32 option, fontdef_t font); @@ -273,6 +272,7 @@ INT32 V_FontStringHeight(const char *string, fontdef_t font); #define V_ThinStringWidth(str,o) V_FontStringWidth(str,o,tny_font) #define V_SmallThinStringWidth(str,o) V_FontStringWidth(str,o,tny_font)/2 #define V_CreditStringWidth(str) V_FontStringWidth(str,0,cred_font) +#define V_NameTagWidth(str) V_FontStringWidth(str,0,ntb_font) #define V_LevelNameWidth(str) V_FontStringWidth(str,V_ALLOWLOWERCASE,lt_font) #define V_LevelNameHeight(str) V_FontStringHeight(str,lt_font)