diff --git a/src/v_video.c b/src/v_video.c index dcfbc7ce524433956f69067c5a5cfe7dec9140a4..93d33d8d0c552ed9fc552cb0e91551567fd75a7b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2141,10 +2141,8 @@ char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) return newstring; } -// // Write a string using a supplied font and scale // NOTE: the text is centered for screens larger than the base width -// void V_DrawFontString(INT32 x, INT32 y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font) { V_DrawFontStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, width, height, option, scale, string, font); @@ -2161,10 +2159,8 @@ void V_DrawRightAlignedFontString(INT32 x, INT32 y, INT32 width, INT32 height, I V_DrawRightAlignedFontStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, width, height, option, scale, string, font); } -// // Write a string using a supplied font and scale at a fixed position // NOTE: the text is centered for screens larger than the base width -// void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font) { fixed_t cx = x, cy = y; @@ -2269,17 +2265,14 @@ void V_DrawCenteredFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT32 he V_DrawFontStringAtFixed(x, y, width, height, option, scale, string, font); } - void V_DrawRightAlignedFontStringAtFixed(fixed_t x, fixed_t y, INT32 width, INT32 height, INT32 option, fixed_t scale, const char *string, patch_t **font) { x -= V_FontStringWidth(string, option, width, font)*scale; V_DrawFontStringAtFixed(x, y, width, height, option, scale, string, font); } -// // Write a string using the hu_font // NOTE: the text is centered for screens larger than the base width -// void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) { V_DrawFontString(x, y, 8, 12, option, FRACUNIT, string, hu_font); @@ -2295,10 +2288,8 @@ void V_DrawRightAlignedString(INT32 x, INT32 y, INT32 option, const char *string V_DrawRightAlignedFontString(x, y, 8, 12, option, FRACUNIT, string, hu_font); } -// // Write a string using the hu_font, 0.5x scale // NOTE: the text is centered for screens larger than the base width -// void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) { V_DrawFontString(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); @@ -2314,10 +2305,8 @@ void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *s V_DrawRightAlignedFontString(x, y, 8, 12, option, FRACUNIT/2, string, hu_font); } -// // Write a string using the tny_font // NOTE: the text is centered for screens larger than the base width -// void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) { V_DrawFontString(x, y, 5, 12, option, FRACUNIT, string, tny_font); @@ -2333,11 +2322,8 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st V_DrawRightAlignedFontString(x, y, 5, 12, option, FRACUNIT, string, tny_font); } -// // Write a string using the tny_font, 0.5x scale // NOTE: the text is centered for screens larger than the base width -// -// Literally a wrapper. ~Golden void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) { V_DrawSmallThinStringAtFixed((fixed_t)x<<FRACBITS, (fixed_t)y<<FRACBITS, option, string); @@ -2393,14 +2379,12 @@ void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *str void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) { - x -= (V_ThinStringWidth(string, option) / 2)<<FRACBITS; - V_DrawThinStringAtFixed(x, y, option, string); + V_DrawCenteredThinStringAtFixed(x, y, option, string); } void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) { - x -= V_ThinStringWidth(string, option)<<FRACBITS; - V_DrawThinStringAtFixed(x, y, option, string); + V_DrawRightAlignedThinStringAtFixed(x, y, option, string); } // Draws a small string at a fixed_t location. @@ -2886,21 +2870,21 @@ INT16 V_LevelActNumWidth(UINT8 num) } // -// Find string width from hu_font chars +// Find string width from supplied font characters // -INT32 V_StringWidth(const char *string, INT32 option) +INT32 V_FontStringWidth(const char *string, INT32 option, INT32 width, patch_t **font) { INT32 c, w = 0; - INT32 spacewidth = 4, charwidth = 0; + INT32 spacewidth = width/2, charwidth = 0; size_t i; switch (option & V_SPACINGMASK) { case V_MONOSPACE: - spacewidth = 8; + spacewidth = width; /* FALLTHRU */ case V_OLDSPACING: - charwidth = 8; + charwidth = width; break; case V_6WIDTHSPACE: spacewidth = 6; @@ -2913,10 +2897,10 @@ INT32 V_StringWidth(const char *string, INT32 option) if (string[i] & 0x80) continue; c = toupper(string[i]) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) + if (c < 0 || c >= HU_FONTSIZE || !font[c]) w += spacewidth; else - w += (charwidth ? charwidth : hu_font[c]->width); + w += (charwidth ? charwidth : (font[c]->width)); } if (option & (V_NOSCALESTART|V_NOSCALEPATCH)) @@ -2925,130 +2909,35 @@ INT32 V_StringWidth(const char *string, INT32 option) return w; } -// +// Find string width from hu_font chars +INT32 V_StringWidth(const char *string, INT32 option) +{ + return V_FontStringWidth(string, option, 8, hu_font); +} + // Find string width from hu_font chars, 0.5x scale -// INT32 V_SmallStringWidth(const char *string, INT32 option) { - INT32 c, w = 0; - INT32 spacewidth = 2, charwidth = 0; - size_t i; - - switch (option & V_SPACINGMASK) - { - case V_MONOSPACE: - spacewidth = 4; - /* FALLTHRU */ - case V_OLDSPACING: - charwidth = 4; - break; - case V_6WIDTHSPACE: - spacewidth = 3; - default: - break; - } - - for (i = 0; i < strlen(string); i++) - { - if (string[i] & 0x80) - continue; - c = toupper(string[i]) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) - w += spacewidth; - else - w += (charwidth ? charwidth : (hu_font[c]->width / 2)); - } - - return w; + return V_FontStringWidth(string, option, 8, hu_font)/2; } -// + // Find string width from tny_font chars -// INT32 V_ThinStringWidth(const char *string, INT32 option) { - INT32 c, w = 0; - INT32 spacewidth = 2, charwidth = 0; - size_t i; - - switch (option & V_SPACINGMASK) - { - case V_MONOSPACE: - spacewidth = 5; - /* FALLTHRU */ - case V_OLDSPACING: - charwidth = 5; - break; - case V_6WIDTHSPACE: - spacewidth = 3; - default: - break; - } - - for (i = 0; i < strlen(string); i++) - { - if (string[i] & 0x80) - continue; - c = toupper(string[i]) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) - w += spacewidth; - else - w += (charwidth ? charwidth : tny_font[c]->width); - } - - return w; + return V_FontStringWidth(string, option, 5, tny_font); } -// // Find string width from tny_font chars, 0.5x scale -// INT32 V_SmallThinStringWidth(const char *string, INT32 option) { - INT32 w = V_ThinStringWidth(string, option)<<FRACBITS; - return w/2 + FRACUNIT; // +FRACUNIT because otherwise it's offset wrong. + return V_FontStringWidth(string, option, 5, tny_font)/2; } boolean *heatshifter = NULL; INT32 lastheight = 0; INT32 heatindex[2] = { 0, 0 }; -// -// Find string width from supplied font characters -// -INT32 V_FontStringWidth(const char *string, INT32 option, INT32 width, patch_t **font) -{ - INT32 c, w = 0; - INT32 spacewidth = width/2, charwidth = 0; - size_t i; - - switch (option & V_SPACINGMASK) - { - case V_MONOSPACE: - spacewidth = width; - /* FALLTHRU */ - case V_OLDSPACING: - charwidth = width; - break; - case V_6WIDTHSPACE: - spacewidth = 6; - default: - break; - } - - for (i = 0; i < strlen(string); i++) - { - if (string[i] & 0x80) - continue; - c = toupper(string[i]) - HU_FONTSTART; - if (c < 0 || c >= HU_FONTSIZE || !font[c]) - w += spacewidth; - else - w += (charwidth ? charwidth : (font[c]->width)); - } - - return w; -} - // // V_DoPostProcessor // diff --git a/src/v_video.h b/src/v_video.h index 414172eec41426bae827c1f96d4f9a1843519c04..3bcac674ad2b329f6cc430713385f7c3c52f7880 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -275,6 +275,8 @@ void V_DrawNameTag(INT32 x, INT32 y, INT32 option, fixed_t scale, UINT8 *basecol INT32 V_CountNameTagLines(const char *string); INT32 V_NameTagWidth(const char *string); +// Find string width from supplied font chars +INT32 V_FontStringWidth(const char *string, INT32 option, INT32 width, patch_t **font); // Find string width from hu_font chars INT32 V_StringWidth(const char *string, INT32 option); // Find string width from hu_font chars, 0.5x scale @@ -283,8 +285,6 @@ INT32 V_SmallStringWidth(const char *string, INT32 option); INT32 V_ThinStringWidth(const char *string, INT32 option); // Find string width from tny_font chars, 0.5x scale INT32 V_SmallThinStringWidth(const char *string, INT32 option); -// Find string width from supplied font chars -INT32 V_FontStringWidth(const char *string, INT32 option, INT32 width, patch_t **font); void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param);