fix MN_GetFon2PixelWidth for 0 width characters, rename spacing->kerning

This commit is contained in:
Roman Fomin 2024-03-14 11:13:22 +07:00
parent 507fd4ed59
commit 29653b2e1a
4 changed files with 17 additions and 11 deletions

View File

@ -2743,7 +2743,7 @@ void D_DoomMain(void)
I_Printf(VB_INFO, "HU_Init: Setting up heads up display.");
HU_Init();
MN_SetMenuFontSpacing();
MN_SetHUFontKerning();
I_Printf(VB_INFO, "ST_Init: Init status bar.");
ST_Init();

View File

@ -193,7 +193,7 @@ boolean MN_DrawFon2String(int x, int y, byte *cr, const char *str)
}
else
{
cx += FON2_SPACE + kerning;
cx += FON2_SPACE;
}
}
@ -221,7 +221,14 @@ int MN_GetFon2PixelWidth(const char *str)
continue;
}
len += chars[c].width + kerning;
if (chars[c].width)
{
len += chars[c].width + kerning;
}
else
{
len += FON2_SPACE;
}
}
len -= kerning;
return len;

View File

@ -62,7 +62,7 @@ void MN_SetupResetMenu(void);
void MN_SetupResetMenuVideo(void);
void MN_ResetTimeScale(void);
void MN_DrawCredits(void); // killough 11/98
void MN_SetMenuFontSpacing(void);
void MN_SetHUFontKerning(void);
void MN_DisableVoxelsRenderingItem(void);
extern int traditional_menu; // display the menu traditional way

View File

@ -2630,7 +2630,7 @@ static int M_GetKeyString(int c, int offset)
return offset;
}
static int menu_font_spacing = 0;
static int kerning = 0;
void MN_DrawStringCR(int cx, int cy, byte *cr1, byte *cr2, const char *ch)
{
@ -2686,7 +2686,7 @@ void MN_DrawStringCR(int cx, int cy, byte *cr1, byte *cr2, const char *ch)
// The screen is cramped, so trim one unit from each
// character so they butt up against each other.
cx += w + menu_font_spacing;
cx += w + kerning;
}
}
@ -2755,10 +2755,9 @@ int MN_GetPixelWidth(const char *ch)
}
len += SHORT(hu_font[c]->width);
len += menu_font_spacing; // adjust so everything fits
len += kerning; // adjust so everything fits
}
len -=
menu_font_spacing; // replace what you took away on the last char only
len -= kerning; // replace what you took away on the last char only
return len;
}
@ -3684,11 +3683,11 @@ int MN_StringWidth(const char *string)
return w;
}
void MN_SetMenuFontSpacing(void)
void MN_SetHUFontKerning(void)
{
if (MN_StringWidth("abcdefghijklmnopqrstuvwxyz01234") > 230)
{
menu_font_spacing = -1;
kerning = -1;
}
}