Navigation Menu

Skip to content

Commit

Permalink
- allow switching between the two Duke BigFonts and fix Y in Duke's B…
Browse files Browse the repository at this point in the history
…igFont13.
  • Loading branch information
coelckers committed May 31, 2021
1 parent 90bcba3 commit d174b61
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 12 deletions.
4 changes: 2 additions & 2 deletions source/common/fonts/font.cpp
Expand Up @@ -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;
}
Expand Down
7 changes: 0 additions & 7 deletions source/common/fonts/v_font.cpp
Expand Up @@ -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;

Expand Down
22 changes: 21 additions & 1 deletion source/common/fonts/v_font.h
Expand Up @@ -99,6 +99,7 @@ class FFont
};

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;
Expand Down Expand Up @@ -141,6 +142,7 @@ class FFont
bool NoTranslate() const { return noTranslate; }
virtual void RecordAllTextureColors(uint32_t *usedcolors);
void CheckCase();
void SetName(FName nm) { FontName = nm; }

int GetDisplacement() const { return Displacement; }

Expand All @@ -149,8 +151,26 @@ class FFont

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();

Expand Down
2 changes: 1 addition & 1 deletion source/common/statusbar/base_sbar.cpp
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions source/core/gamecontrol.cpp
Expand Up @@ -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);
Expand Down
24 changes: 23 additions & 1 deletion source/core/razefont.cpp
Expand Up @@ -33,6 +33,8 @@
*/

#include "razefont.h"
#include "gamecontrol.h"
#include "c_cvars.h"
#include "i_interface.h"

FGameTexture* GetBaseForChar(FGameTexture* t);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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.
}
3 changes: 3 additions & 0 deletions 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;
Expand Down
Binary file modified wadsrc/static/filter/duke/fonts/bigfont13/0059.lmp
Binary file not shown.

0 comments on commit d174b61

Please sign in to comment.