Add character width to font definitions

Used for V_MONOSPACE and V_OLDSPACING instead of spacewidth*2
This commit is contained in:
spherallic 2024-03-07 21:36:59 +01:00
parent 94db9ddf12
commit 02f31a4922
3 changed files with 17 additions and 15 deletions

View file

@ -200,13 +200,13 @@ void HU_LoadGraphics(void)
HU_LoadFontCharacters(&ntb_font, "NTFNT"); HU_LoadFontCharacters(&ntb_font, "NTFNT");
HU_LoadFontCharacters(&nto_font, "NTFNO"); HU_LoadFontCharacters(&nto_font, "NTFNO");
// Set kerning, space width & line spacing for each font // For each font, set kerning, space width, character width and line spacing
HU_SetFontProperties(&hu_font, 0, 4, 12); HU_SetFontProperties(&hu_font, 0, 4, 8, 12);
HU_SetFontProperties(&tny_font, 0, 2, 12); HU_SetFontProperties(&tny_font, 0, 2, 4, 12);
HU_SetFontProperties(&cred_font, 0, 16, 16); HU_SetFontProperties(&cred_font, 0, 16, 16, 16);
HU_SetFontProperties(&lt_font, 0, 16, 20); HU_SetFontProperties(&lt_font, 0, 16, 20, 20);
HU_SetFontProperties(&ntb_font, 2, 4, 21); HU_SetFontProperties(&ntb_font, 2, 4, 20, 21);
HU_SetFontProperties(&nto_font, 0, 4, 21); HU_SetFontProperties(&nto_font, 0, 4, 20, 21);
//cache numbers too! //cache numbers too!
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
@ -279,10 +279,11 @@ void HU_LoadFontCharacters(fontdef_t *font, const char *prefix)
} }
} }
void HU_SetFontProperties(fontdef_t *font, INT32 kerning, UINT32 spacewidth, UINT32 linespacing) void HU_SetFontProperties(fontdef_t *font, INT32 kerning, UINT32 spacewidth, UINT32 charwidth, UINT32 linespacing)
{ {
font->kerning = kerning; font->kerning = kerning;
font->spacewidth = spacewidth; font->spacewidth = spacewidth;
font->charwidth = charwidth;
font->linespacing = linespacing; font->linespacing = linespacing;
} }

View file

@ -35,6 +35,7 @@ typedef struct
patch_t *chars[FONTSIZE]; patch_t *chars[FONTSIZE];
INT32 kerning; INT32 kerning;
UINT32 spacewidth; UINT32 spacewidth;
UINT32 charwidth;
UINT32 linespacing; UINT32 linespacing;
} fontdef_t; } fontdef_t;
@ -94,7 +95,7 @@ void HU_Init(void);
void HU_LoadGraphics(void); void HU_LoadGraphics(void);
void HU_LoadFontCharacters(fontdef_t *font, const char *prefix); void HU_LoadFontCharacters(fontdef_t *font, const char *prefix);
void HU_SetFontProperties(fontdef_t *font, INT32 kerning, UINT32 spacewidth, UINT32 linespacing); void HU_SetFontProperties(fontdef_t *font, INT32 kerning, UINT32 spacewidth, UINT32 charwidth, UINT32 linespacing);
// reset heads up when consoleplayer respawns. // reset heads up when consoleplayer respawns.
void HU_Start(void); void HU_Start(void);

View file

@ -1961,10 +1961,10 @@ char *V_FontWordWrap(INT32 x, INT32 w, INT32 option, fixed_t scale, const char *
switch (option & V_SPACINGMASK) switch (option & V_SPACINGMASK)
{ {
case V_MONOSPACE: case V_MONOSPACE:
spacewidth = font.spacewidth*2; spacewidth = font.charwidth;
/* FALLTHRU */ /* FALLTHRU */
case V_OLDSPACING: case V_OLDSPACING:
charwidth = font.spacewidth*2; charwidth = font.charwidth;
break; break;
case V_6WIDTHSPACE: case V_6WIDTHSPACE:
spacewidth = 6; spacewidth = 6;
@ -2057,10 +2057,10 @@ void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t pscale,
switch (option & V_SPACINGMASK) // TODO: 2.3: drop support for these crusty flags switch (option & V_SPACINGMASK) // TODO: 2.3: drop support for these crusty flags
{ {
case V_MONOSPACE: case V_MONOSPACE:
spacewidth = font.spacewidth*2; spacewidth = font.charwidth;
/* FALLTHRU */ /* FALLTHRU */
case V_OLDSPACING: case V_OLDSPACING:
charwidth = font.spacewidth*2; charwidth = font.charwidth;
break; break;
case V_6WIDTHSPACE: case V_6WIDTHSPACE:
spacewidth = 6; spacewidth = 6;
@ -2432,10 +2432,10 @@ INT32 V_FontStringWidth(const char *string, INT32 option, fontdef_t font)
switch (option & V_SPACINGMASK) switch (option & V_SPACINGMASK)
{ {
case V_MONOSPACE: case V_MONOSPACE:
spacewidth = font.spacewidth*2; spacewidth = font.charwidth;
/* FALLTHRU */ /* FALLTHRU */
case V_OLDSPACING: case V_OLDSPACING:
charwidth = font.spacewidth*2; charwidth = font.charwidth;
break; break;
case V_6WIDTHSPACE: case V_6WIDTHSPACE:
spacewidth = 6; spacewidth = 6;