diff --git a/source/common/fonts/font.cpp b/source/common/fonts/font.cpp index 0a82366c9..5149065b9 100644 --- a/source/common/fonts/font.cpp +++ b/source/common/fonts/font.cpp @@ -1007,10 +1007,10 @@ void FFont::LoadTranslations() // //========================================================================== -FFont::FFont (int lump) +FFont::FFont (int lump, FName nm) { Lump = lump; - FontName = NAME_None; + FontName = nm; Cursor = '_'; noTranslate = false; } diff --git a/source/common/fonts/v_font.cpp b/source/common/fonts/v_font.cpp index 0fd688fc4..dd10b540e 100644 --- a/source/common/fonts/v_font.cpp +++ b/source/common/fonts/v_font.cpp @@ -103,13 +103,6 @@ FFont *V_GetFont(const char *name, const char *fontlumpname) if (font) return font; } - // This is only temporary until virtual fonts get implemented - if (!stricmp(name, "BIGFONT")) - { - font = V_GetFont("BIGFONT15"); - if (font) return font; - } - int lump = -1; int folderfile = -1; diff --git a/source/common/fonts/v_font.h b/source/common/fonts/v_font.h index 7abaefaa5..72fd49e29 100644 --- a/source/common/fonts/v_font.h +++ b/source/common/fonts/v_font.h @@ -99,6 +99,7 @@ public: }; FFont (const char *fontname, const char *nametemplate, const char *filetemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false, bool iwadonly = false, bool doomtemplate = false, GlyphSet *baseGlpyphs = nullptr); + FFont(int lump, FName nm = NAME_None); virtual ~FFont (); virtual FGameTexture *GetChar (int code, int translation, int *const width) const; @@ -141,6 +142,7 @@ public: bool NoTranslate() const { return noTranslate; } virtual void RecordAllTextureColors(uint32_t *usedcolors); void CheckCase(); + void SetName(FName nm) { FontName = nm; } int GetDisplacement() const { return Displacement; } @@ -149,8 +151,26 @@ public: friend void V_InitCustomFonts(); + void CopyFrom(const FFont& other) + { + Type = other.Type; + FirstChar = other.FirstChar; + LastChar = other.LastChar; + SpaceWidth = other.SpaceWidth; + FontHeight = other.FontHeight; + GlobalKerning = other.GlobalKerning; + TranslationType = other.TranslationType; + Displacement = other.Displacement; + Cursor = other.Cursor; + noTranslate = other.noTranslate; + MixedCase = other.MixedCase; + forceremap = other.forceremap; + Chars = other.Chars; + Translations = other.Translations; + Lump = other.Lump; + } + protected: - FFont (int lump); void FixXMoves(); diff --git a/source/common/statusbar/base_sbar.cpp b/source/common/statusbar/base_sbar.cpp index 9d9c4b58c..e63c21fb2 100644 --- a/source/common/statusbar/base_sbar.cpp +++ b/source/common/statusbar/base_sbar.cpp @@ -836,7 +836,7 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt, int style) { - if (font == nullptr) ThrowAbortException(X_READ_NIL, nullptr); + if (font == nullptr || font->mFont == nullptr) ThrowAbortException(X_READ_NIL, nullptr); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); // resolve auto-alignment before making any adjustments to the position values. diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 5c8e7335b..44d678f9b 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1026,6 +1026,7 @@ int RunGame() lookups.postLoadTables(); PostLoadSetup(); lookups.postLoadLookups(); + duke_menufont.Callback(); V_LoadTranslations(); // loading the translations must be delayed until the palettes have been fully set up. FMaterial::SetLayerCallback(setpalettelayer); diff --git a/source/core/razefont.cpp b/source/core/razefont.cpp index a07443a7f..6c4b94f3b 100644 --- a/source/core/razefont.cpp +++ b/source/core/razefont.cpp @@ -33,6 +33,8 @@ */ #include "razefont.h" +#include "gamecontrol.h" +#include "c_cvars.h" #include "i_interface.h" FGameTexture* GetBaseForChar(FGameTexture* t); @@ -41,6 +43,20 @@ void FontCharCreated(FGameTexture* base, FGameTexture* glyph); FFont* IndexFont; FFont* DigiFont; +FFont* BigFont13, * BigFont15; + +CUSTOM_CVAR(Int, duke_menufont, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (!(g_gameType & GAMEFLAG_DUKE) || !BigFont13 || !BigFont15) return; + if (self < -1 || self > 1) self = -1; + else + { + // Font info must be copied so that BigFont does not change its address. + if (self == 0 || (self == -1 && isPlutoPak())) BigFont->CopyFrom(*BigFont15); + else if (self == 1 || (self == -1 && !isPlutoPak())) BigFont->CopyFrom(*BigFont13); + } +} + static void SetupHires(FFont *font) { @@ -78,6 +94,12 @@ void InitFont() SetupHires(BigFont); SetupHires(SmallFont); + if (g_gameType & GAMEFLAG_DUKE) + { + BigFont13 = V_GetFont("BigFont13"); + BigFont15 = V_GetFont("BigFont15"); + BigFont = new FFont(0, "BigFont"); + } + // todo: Compare small and big fonts with the base font and decide which one to use. - // todo: Allow Duke to select between both variants. } diff --git a/source/core/razefont.h b/source/core/razefont.h index 0228e6a7f..27855e9ca 100644 --- a/source/core/razefont.h +++ b/source/core/razefont.h @@ -1,5 +1,8 @@ #pragma once #include "v_font.h" +#include "c_cvars.h" + +EXTERN_CVAR(Int, duke_menufont) extern FFont* IndexFont; extern FFont* DigiFont; diff --git a/wadsrc/static/filter/duke/fonts/bigfont13/0059.lmp b/wadsrc/static/filter/duke/fonts/bigfont13/0059.lmp index 9e02a1bd5..4c3059047 100644 Binary files a/wadsrc/static/filter/duke/fonts/bigfont13/0059.lmp and b/wadsrc/static/filter/duke/fonts/bigfont13/0059.lmp differ