Add kerning option to fontdefs, rename width and height.

This commit is contained in:
spherallic 2022-02-04 13:36:27 +01:00
parent 908fb8b026
commit b8cae8e735
3 changed files with 18 additions and 15 deletions

View file

@ -206,11 +206,13 @@ void HU_LoadGraphics(void)
tny_font.chars[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
hu_font.width = 8;
hu_font.height = 12;
hu_font.kerning = 0;
hu_font.spacewidth = 4;
hu_font.linespacing = 12;
tny_font.width = 5;
tny_font.height = 12;
tny_font.kerning = 0;
tny_font.spacewidth = 2;
tny_font.linespacing = 12;
j = LT_FONTSTART;
for (i = 0; i < LT_FONTSIZE; i++)

View file

@ -49,8 +49,9 @@ extern char english_shiftxform[];
typedef struct
{
patch_t *chars[HU_FONTSIZE];
INT32 width;
INT32 height;
INT32 kerning;
UINT32 spacewidth;
UINT32 linespacing;
} fontdef_t;
extern fontdef_t hu_font, tny_font;

View file

@ -2166,7 +2166,7 @@ void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t pscale,
INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0;
const char *ch = string;
INT32 charflags = (option & V_CHARCOLORMASK);
INT32 spacewidth = font.width/2, charwidth = 0;
INT32 spacewidth = font.spacewidth, charwidth = 0;
INT32 lowercase = (option & V_ALLOWLOWERCASE);
option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE...
@ -2192,10 +2192,10 @@ void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t pscale,
switch (option & V_SPACINGMASK) // TODO: drop support for these crusty flags in the next major update
{
case V_MONOSPACE:
spacewidth = font.width;
spacewidth = font.spacewidth*2;
/* FALLTHRU */
case V_OLDSPACING:
charwidth = font.width;
charwidth = font.spacewidth*2;
break;
case V_6WIDTHSPACE:
spacewidth = 6;
@ -2221,7 +2221,7 @@ void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t pscale,
if (option & V_RETURN8)
cy += FixedMul((8<<FRACBITS), dupy);
else
cy += FixedMul((font.height<<FRACBITS), dupy);
cy += FixedMul((font.linespacing<<FRACBITS), dupy);
continue;
}
@ -2255,7 +2255,7 @@ void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t pscale,
V_DrawStretchyFixedPatch(cx + center, cy, pscale, vscale, option, font.chars[c], V_GetStringColormap(charflags));
cx += w;
cx += w + (font.kerning<<FRACBITS);
}
}
@ -2742,16 +2742,16 @@ INT16 V_LevelActNumWidth(UINT8 num)
INT32 V_FontStringWidth(const char *string, INT32 option, fontdef_t font)
{
INT32 c, w = 0;
INT32 spacewidth = font.width/2, charwidth = 0;
INT32 spacewidth = font.spacewidth, charwidth = 0;
size_t i;
switch (option & V_SPACINGMASK)
{
case V_MONOSPACE:
spacewidth = font.width;
spacewidth = font.spacewidth*2;
/* FALLTHRU */
case V_OLDSPACING:
charwidth = font.width;
charwidth = font.spacewidth*2;
break;
case V_6WIDTHSPACE:
spacewidth = 6;
@ -2767,7 +2767,7 @@ INT32 V_FontStringWidth(const char *string, INT32 option, fontdef_t font)
if (c < 0 || c >= HU_FONTSIZE || !font.chars[c])
w += spacewidth;
else
w += (charwidth ? charwidth : (font.chars[c]->width));
w += (charwidth ? charwidth : (font.chars[c]->width)) + font.kerning;
}
if (option & (V_NOSCALESTART|V_NOSCALEPATCH))