diff --git a/src/gamedata/fonts/font.cpp b/src/gamedata/fonts/font.cpp index c35f933e9..aa0a7af80 100644 --- a/src/gamedata/fonts/font.cpp +++ b/src/gamedata/fonts/font.cpp @@ -290,6 +290,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla auto count = maxchar - minchar + 1; Chars.Resize(count); int fontheight = 0; + int asciiheight = 0; for (i = 0; i < count; i++) { @@ -311,6 +312,10 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla { fontheight = height; } + if (height > asciiheight && FirstChar + 1 < 128) + { + asciiheight = height; + } } pic->SetUseType(ETextureType::FontChar); @@ -352,6 +357,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla } } if (FontHeight == 0) FontHeight = fontheight; + if (AsciiHeight == 0) AsciiHeight = asciiheight; FixXMoves(); } diff --git a/src/gamedata/fonts/v_font.h b/src/gamedata/fonts/v_font.h index caaa0f27a..6eff7e009 100644 --- a/src/gamedata/fonts/v_font.h +++ b/src/gamedata/fonts/v_font.h @@ -146,6 +146,7 @@ protected: int FirstChar, LastChar; int SpaceWidth; int FontHeight; + int AsciiHeight = 0; int GlobalKerning; int TranslationType = 0; int Displacement = 0; diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index c3d5b8a13..d2ffc0c73 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2000,6 +2000,17 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetHeight, GetHeight) ACTION_RETURN_INT(self->GetHeight()); } +static int GetDisplacement(FFont* font) +{ + return font->GetDisplacement(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDisplacement, GetDisplacement) +{ + PARAM_SELF_STRUCT_PROLOGUE(FFont); + ACTION_RETURN_INT(self->GetDisplacement()); +} + double GetBottomAlignOffset(FFont *font, int c); DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetBottomAlignOffset, GetBottomAlignOffset) { diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 0e2f0708b..636b60701 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -322,6 +322,7 @@ struct Font native native int StringWidth(String code); native bool CanPrint(String code); native int GetHeight(); + native int GetDisplacement(); native String GetCursor(); native static int FindFontColor(Name color); diff --git a/wadsrc/static/zscript/ui/statscreen/statscreen.zs b/wadsrc/static/zscript/ui/statscreen/statscreen.zs index 7cd776062..699790308 100644 --- a/wadsrc/static/zscript/ui/statscreen/statscreen.zs +++ b/wadsrc/static/zscript/ui/statscreen/statscreen.zs @@ -149,21 +149,19 @@ class StatusScreen abstract play version("2.5") // //==================================================================== - int DrawName(int y, TextureID tex, String levelname) + int, int DrawName(int y, TextureID tex, String levelname) { // draw if (tex.isValid()) { - int w,h; - [w, h] = TexMan.GetSize(tex); let size = TexMan.GetScaledSize(tex); screen.DrawTexture(tex, true, (screen.GetWidth() - size.X * CleanXfac) /2, y, DTA_CleanNoMove, true); - if (h > 50) + if (size.Y > 50) { // Fix for Deus Vult II and similar wads that decide to make these hugely tall // patches with vast amounts of empty space at the bottom. - size.Y = TexMan.CheckRealHeight(tex) * size.Y / h; + size.Y = TexMan.CheckRealHeight(tex); } - return y + (h + BigFont.GetHeight()/4) * CleanYfac; + return y + int(Size.Y), (BigFont.GetHeight() - BigFont.GetDisplacement()) * CleanYfac / 4; } else if (levelname.Length() > 0) { @@ -178,9 +176,9 @@ class StatusScreen abstract play version("2.5") screen.DrawText(mapname.mFont, mapname.mColor, (screen.GetWidth() - lines.StringWidth(i) * CleanXfac) / 2, y + h, lines.StringAt(i), DTA_CleanNoMove, true); h += lumph; } - return y + h + lumph/4; + return y + h, (mapname.mFont.GetHeight() - mapname.mFont.GetDisplacement())/4; } - return 0; + return 0, 0; } //==================================================================== @@ -235,11 +233,15 @@ class StatusScreen abstract play version("2.5") virtual int drawLF () { int y = TITLEY * CleanYfac; + int h; + + [y, h] = DrawName(y, wbs.LName0, lnametexts[0]); - y = DrawName(y, wbs.LName0, lnametexts[0]); - // Adjustment for different font sizes for map name and 'finished'. - y -= ((mapname.mFont.GetHeight() - finished.mFont.GetHeight()) * CleanYfac) / 4; + let fontspace1 = finished.mFont.GetDisplacement(); + let fontspace2 = ((h + (finished.mFont.GetHeight() - fontspace1)/4)) / 2; + + y += max(0, fontspace2 - fontspace1) * CleanYFac; // draw "Finished!" @@ -267,7 +269,16 @@ class StatusScreen abstract play version("2.5") int y = TITLEY * CleanYfac; y = DrawPatchOrText(y, entering, enteringPatch, "$WI_ENTERING"); - y += entering.mFont.GetHeight() * CleanYfac / 4; + let h = (entering.mFont.GetHeight() - entering.mFont.GetDisplacement()) / 4; + + if (!wbs.LName1.isValid()) + { + // Factor out the font's displacement here. + let fontspace1 = mapname.mFont.GetDisplacement(); + let fontspace2 = ((h + (mapname.mFont.GetHeight() - fontspace1)/4)) / 2; + h = max(0, fontspace2 - fontspace1) * CleanYFac; + } + y += h * CleanYFac; DrawName(y, wbs.LName1, lnametexts[1]); }