diff --git a/src/c_console.cpp b/src/c_console.cpp index 8693b57d4..7965a6643 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -581,11 +581,6 @@ CUSTOM_CVAR (Int, msgmidcolor2, 4, CVAR_ARCHIVE) setmsgcolor (PRINTLEVELS+1, self); } -EColorRange C_GetDefaultFontColor() -{ - return CR_UNTRANSLATED; -} - FFont * C_GetDefaultHUDFont() { return generic_ui? NewSmallFont : SmallFont; diff --git a/src/g_statusbar/hudmessages.cpp b/src/g_statusbar/hudmessages.cpp index 3ec35b205..33d1daacc 100644 --- a/src/g_statusbar/hudmessages.cpp +++ b/src/g_statusbar/hudmessages.cpp @@ -197,7 +197,14 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h Top = y; HoldTics = (int)(holdTime * TICRATE); Tics = -1; // -1 to compensate for one additional Tick the message will receive. - Font = font? font : generic_ui? NewSmallFont : AlternativeSmallFont; + + // Try to find the optimal font if none is specified. Prefer SmallFont, but if that cannot handle this text use the IWAD's SmallFont and if that doesn't work either, use the VGA font. + if (font) Font = font; + else if (generic_ui) Font = NewSmallFont; + else if (SmallFont->CanPrint(text)) Font = SmallFont; + else if (OriginalSmallFont->CanPrint(text)) Font = OriginalSmallFont; + else Font = NewSmallFont; + TextColor = textColor; State = 0; SourceText = copystring (text); diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 1ec2be607..0d942f0f3 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -609,6 +609,7 @@ void DBaseStatusBar::DoDrawAutomapHUD(int crdefault, int highlight) if (!generic_ui) { + // If the original font does not have accents this will strip them - but a fallback to the VGA font is not desirable here for such cases. if (!font->CanPrint(GStrings("AM_MONSTERS")) || !font->CanPrint(GStrings("AM_SECRETS")) || !font->CanPrint(GStrings("AM_ITEMS"))) font2 = OriginalSmallFont; } diff --git a/src/gamedata/fonts/font.cpp b/src/gamedata/fonts/font.cpp index 7a74daf75..c3ea17f25 100644 --- a/src/gamedata/fonts/font.cpp +++ b/src/gamedata/fonts/font.cpp @@ -1019,6 +1019,7 @@ double GetBottomAlignOffset(FFont *font, int c) bool FFont::CanPrint(const uint8_t *string) const { + if (!string) return true; while (*string) { auto chr = GetCharFromString(string); @@ -1042,7 +1043,7 @@ bool FFont::CanPrint(const uint8_t *string) const else if (chr != '\n') { int cc = GetCharCode(chr, true); - if (chr != cc) + if (chr != cc && iswalpha(chr)) { return false; } diff --git a/src/gamedata/fonts/v_font.cpp b/src/gamedata/fonts/v_font.cpp index 8aef25240..c4e2dc792 100644 --- a/src/gamedata/fonts/v_font.cpp +++ b/src/gamedata/fonts/v_font.cpp @@ -1601,6 +1601,10 @@ void V_InitFonts() { BigFont = NewSmallFont; } + if (OriginalSmallFont == nullptr) + { + OriginalSmallFont = SmallFont; + } AlternativeSmallFont = OriginalSmallFont; UpdateGenericUI(false); } diff --git a/src/gamedata/fonts/v_font.h b/src/gamedata/fonts/v_font.h index a4486cf37..797fda94f 100644 --- a/src/gamedata/fonts/v_font.h +++ b/src/gamedata/fonts/v_font.h @@ -183,7 +183,6 @@ EColorRange V_ParseFontColor (const uint8_t *&color_value, int normalcolor, int FFont *V_GetFont(const char *fontname, const char *fontlumpname = nullptr); void V_InitFontColors(); -EColorRange C_GetDefaultFontColor(); FFont * C_GetDefaultHUDFont(); diff --git a/src/rendering/2d/v_drawtext.cpp b/src/rendering/2d/v_drawtext.cpp index 2e0302dca..46dea6561 100644 --- a/src/rendering/2d/v_drawtext.cpp +++ b/src/rendering/2d/v_drawtext.cpp @@ -181,10 +181,6 @@ void DFrameBuffer::DrawChar (FFont *font, int normalcolor, double x, double y, i int dummy; bool redirected; - // Workaround until this can be automated. - if (font == NewSmallFont && normalcolor == CR_UNTRANSLATED) - normalcolor = C_GetDefaultFontColor(); - if (NULL != (pic = font->GetChar (character, normalcolor, &dummy, &redirected))) { DrawParms parms; @@ -215,11 +211,6 @@ void DFrameBuffer::DrawChar(FFont *font, int normalcolor, double x, double y, in int dummy; bool redirected; - // Workaround until this can be automated. - if (font == NewSmallFont && normalcolor == CR_UNTRANSLATED) - normalcolor = C_GetDefaultFontColor(); - - if (NULL != (pic = font->GetChar(character, normalcolor, &dummy, &redirected))) { DrawParms parms; @@ -274,10 +265,6 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double int kerning; FTexture *pic; - // Workaround until this can be automated. - if (font == NewSmallFont && normalcolor == CR_UNTRANSLATED) - normalcolor = C_GetDefaultFontColor(); - if (parms.celly == 0) parms.celly = font->GetHeight() + 1; parms.celly *= parms.scaley; diff --git a/src/v_video.cpp b/src/v_video.cpp index a968304ed..a431e3537 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -914,6 +914,7 @@ DEFINE_GLOBAL(ConFont) DEFINE_GLOBAL(NewConsoleFont) DEFINE_GLOBAL(NewSmallFont) DEFINE_GLOBAL(AlternativeSmallFont) +DEFINE_GLOBAL(OriginalSmallFont) DEFINE_GLOBAL(IntermissionFont) DEFINE_GLOBAL(CleanXfac) DEFINE_GLOBAL(CleanYfac) diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 4992b503a..4a13897b8 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -25,6 +25,7 @@ struct _ native // These are the global variables, the struct is only here to av native readonly Font NewConsoleFont; native readonly Font NewSmallFont; native readonly Font AlternativeSmallFont; + native readonly Font OriginalSmallFont; native readonly Font intermissionfont; native readonly int CleanXFac; native readonly int CleanYFac; diff --git a/wadsrc/static/zscript/ui/menu/messagebox.zs b/wadsrc/static/zscript/ui/menu/messagebox.zs index 1ed970f35..f86a05ea0 100644 --- a/wadsrc/static/zscript/ui/menu/messagebox.zs +++ b/wadsrc/static/zscript/ui/menu/messagebox.zs @@ -62,7 +62,7 @@ class MessageBoxMenu : Menu mMouseLeft = 140; mMouseY = 0x80000000; - if (generic_ui) + //if (generic_ui) { arrowFont = textFont = NewSmallFont; int factor = (CleanXfac+1) / 2; @@ -70,6 +70,7 @@ class MessageBoxMenu : Menu destHeight = screen.GetHeight() / factor; selector = "▶"; } + /* else { textFont = AlternativeSmallFont; @@ -78,6 +79,7 @@ class MessageBoxMenu : Menu destHeight = CleanHeight; selector = "\xd"; } + */ int mr1 = destWidth/2 + 10 + textFont.StringWidth(Stringtable.Localize("$TXT_YES")); int mr2 = destWidth/2 + 10 + textFont.StringWidth(Stringtable.Localize("$TXT_NO"));