- do not mix game-specified fonts with the extensions for the stock version.

This generally doesn't look good when different colors are mixed or the mismatch in color ranges causes bad translations to be generated.
This commit is contained in:
Christoph Oelckers 2019-04-21 08:09:31 +02:00
parent 44360b00dd
commit fcbde757c9
8 changed files with 105 additions and 32 deletions

View file

@ -787,7 +787,7 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
width = DisplayWidth / active_con_scaletext(generic_ui);
FFont *font = generic_ui ? NewSmallFont : SmallFont;
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
if (font == nullptr) return; // Without an initialized font we cannot handle the message (this is for those which come here before the font system is ready.)
if (AddType == APPENDLINE && Text.Size() > 0 && Text[Text.Size() - 1].PrintLevel == printlevel)
@ -1071,7 +1071,7 @@ void FNotifyBuffer::Draw()
line = Top;
canskip = true;
FFont *font = generic_ui ? NewSmallFont : SmallFont;
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
lineadv = font->GetHeight ();
for (unsigned i = 0; i < Text.Size(); ++ i)

View file

@ -197,7 +197,7 @@ 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 : SmallFont;
Font = font? font : generic_ui? SmallFont : AlternativeSmallFont;
TextColor = textColor;
State = 0;
SourceText = copystring (text);

View file

@ -69,7 +69,7 @@
//
//==========================================================================
FFont::FFont (const char *name, const char *nametemplate, const char *filetemplate, int lfirst, int lcount, int start, int fdlump, int spacewidth, bool notranslate)
FFont::FFont (const char *name, const char *nametemplate, const char *filetemplate, int lfirst, int lcount, int start, int fdlump, int spacewidth, bool notranslate, bool iwadonly)
{
int i;
FTextureID lump;
@ -188,6 +188,8 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
else
{
if (nametemplate != nullptr)
{
if (!iwadonly)
{
for (i = 0; i < lcount; i++)
{
@ -217,6 +219,47 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
}
}
}
else
{
FTexture *texs[256 - '!'] = {};
for (i = 0; i < lcount; i++)
{
TArray<FTextureID> array;
mysnprintf(buffer, countof(buffer), nametemplate, i + start);
TexMan.ListTextures(buffer, array, true);
for (auto entry : array)
{
FTexture *tex = TexMan.GetTexture(entry, false);
if (tex && tex->SourceLump >= 0 && Wads.GetLumpFile(tex->SourceLump) <= Wads.GetIwadNum() && tex->UseType == ETextureType::MiscPatch)
{
texs[i] = tex;
}
}
}
if (doomtemplate)
{
// Handle the misplaced '|'.
if (texs[121 - start] && !texs[120 - start] && !texs[122 - start] && !texs[124 - start])
{
texs[124 - start] = texs[121 - start];
texs[121 - start] = nullptr;
}
}
for (i = 0; i < lcount; i++)
{
if (texs[i])
{
int position = '!' + i;
Type = Multilump;
if (position < minchar) minchar = position;
if (position > maxchar) maxchar = position;
charMap.Insert(position, TexMan.GetTexture(lump));
}
}
}
}
if (folderdata.Size() > 0)
{
// all valid lumps must be named with a hex number that represents its Unicode character index.

View file

@ -1496,15 +1496,42 @@ void V_InitFonts()
if (!(SmallFont = V_GetFont("SmallFont", "SMALLFNT")))
{
if (Wads.CheckNumForName("FONTA_S") >= 0)
{
int wadfile = -1;
auto a = Wads.CheckNumForName("FONTA33", ns_graphics);
if (a != -1) wadfile = Wads.GetLumpFile(a);
if (wadfile > Wads.GetIwadNum())
{
// The font has been replaced, so we need to create a copy of the original as well.
SmallFont = new FFont("SmallFont", "FONTA%02u", nullptr, HU_FONTSTART, HU_FONTSIZE, 1, -1);
SmallFont->SetCursor('[');
OriginalSmallFont = new FFont("SmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1, -1, false, true);
OriginalSmallFont->SetCursor('[');
}
else
{
SmallFont = new FFont("SmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1);
SmallFont->SetCursor('[');
}
}
else if (Wads.CheckNumForName("STCFN033", ns_graphics) >= 0)
{
int wadfile = -1;
auto a = Wads.CheckNumForName("STCFN065", ns_graphics);
if (a != -1) wadfile = Wads.GetLumpFile(a);
if (wadfile > Wads.GetIwadNum())
{
// The font has been replaced, so we need to create a copy of the original as well.
SmallFont = new FFont("SmallFont", "STCFN%.3d", nullptr, HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1);
OriginalSmallFont = new FFont("SmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1, -1, false, true);
}
else
{
SmallFont = new FFont("SmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1);
}
}
}
if (!(SmallFont2 = V_GetFont("SmallFont2"))) // Only used by Strife
{
if (Wads.CheckNumForName("STBFN033", ns_graphics) >= 0)
@ -1566,8 +1593,9 @@ void V_InitFonts()
}
if (BigFont == nullptr)
{
BigFont = SmallFont;
BigFont = NewSmallFont;
}
AlternativeSmallFont = SmallFont;
}
void V_ClearFonts()
@ -1577,6 +1605,6 @@ void V_ClearFonts()
delete FFont::FirstFont;
}
FFont::FirstFont = nullptr;
CurrentConsoleFont = NewSmallFont = NewConsoleFont = SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
AlternativeSmallFont = OriginalSmallFont = CurrentConsoleFont = NewSmallFont = NewConsoleFont = SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
}

View file

@ -93,7 +93,7 @@ public:
Custom
};
FFont (const char *fontname, const char *nametemplate, const char *filetemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false);
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);
virtual ~FFont ();
virtual FTexture *GetChar (int code, int translation, int *const width, bool *redirected = nullptr) const;
@ -164,7 +164,7 @@ protected:
};
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont;
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont, *OriginalSmallFont, *AlternativeSmallFont;
void V_InitFonts();
void V_ClearFonts();

View file

@ -145,7 +145,7 @@ public:
int DisplayWidth, DisplayHeight;
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont;
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont, *OriginalSmallFont, *AlternativeSmallFont;
uint32_t Col2RGB8[65][256];
uint32_t *Col2RGB8_LessPrecision[65];
@ -913,6 +913,7 @@ DEFINE_GLOBAL(BigFont)
DEFINE_GLOBAL(ConFont)
DEFINE_GLOBAL(NewConsoleFont)
DEFINE_GLOBAL(NewSmallFont)
DEFINE_GLOBAL(AlternativeSmallFont)
DEFINE_GLOBAL(IntermissionFont)
DEFINE_GLOBAL(CleanXfac)
DEFINE_GLOBAL(CleanYfac)

View file

@ -24,6 +24,7 @@ struct _ native // These are the global variables, the struct is only here to av
native readonly Font confont;
native readonly Font NewConsoleFont;
native readonly Font NewSmallFont;
native readonly Font AlternativeSmallFont;
native readonly Font intermissionfont;
native readonly int CleanXFac;
native readonly int CleanYFac;

View file

@ -72,7 +72,7 @@ class MessageBoxMenu : Menu
}
else
{
textFont = SmallFont;
textFont = AlternativeSmallFont;
arrowFont = ConFont;
destWidth = CleanWidth;
destHeight = CleanHeight;