mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- changed font loader to detect fonts in folders and to find all default fonts in folders.
This commit is contained in:
parent
e4690b4cd8
commit
fe981c68d3
1 changed files with 68 additions and 57 deletions
|
@ -961,10 +961,22 @@ FFont *V_GetFont(const char *name)
|
|||
if (font == nullptr)
|
||||
{
|
||||
int lump = -1;
|
||||
int folderfile = -1;
|
||||
|
||||
TArray<FolderEntry> folderdata;
|
||||
FStringf path("fonts/%s/", name);
|
||||
|
||||
// Use a folder-based font only if it comes from a later file than the single lump version.
|
||||
if (Wads.GetLumpsInFolder(path, folderdata))
|
||||
{
|
||||
// This assumes that any custom font comes in one piece and not distributed across multiple resource files.
|
||||
folderfile = Wads.GetLumpFile(folderdata[0].lumpnum);
|
||||
}
|
||||
|
||||
|
||||
lump = Wads.CheckNumForFullName(name, true);
|
||||
|
||||
if (lump != -1)
|
||||
if (lump != -1 && Wads.GetLumpFile(lump) >= folderfile)
|
||||
{
|
||||
uint32_t head;
|
||||
{
|
||||
|
@ -974,19 +986,24 @@ FFont *V_GetFont(const char *name)
|
|||
if ((head & MAKE_ID(255,255,255,0)) == MAKE_ID('F','O','N',0) ||
|
||||
head == MAKE_ID(0xE1,0xE6,0xD5,0x1A))
|
||||
{
|
||||
font = new FSingleLumpFont (name, lump);
|
||||
return new FSingleLumpFont (name, lump);
|
||||
}
|
||||
}
|
||||
if (font == nullptr)
|
||||
{
|
||||
FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any);
|
||||
if (picnum.isValid())
|
||||
{
|
||||
font = new FSinglePicFont (name);
|
||||
FTexture *tex = TexMan.GetTexture(picnum);
|
||||
if (tex && tex->GetSourceLump() >= folderfile)
|
||||
{
|
||||
return new FSinglePicFont (name);
|
||||
}
|
||||
}
|
||||
if (folderdata.Size() > 0)
|
||||
{
|
||||
return new FFont(name, nullptr, path, HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||
}
|
||||
return font;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -1023,6 +1040,8 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
|||
TMap<int, FTexture*> charMap;
|
||||
int minchar = INT_MAX;
|
||||
int maxchar = INT_MIN;
|
||||
if (nametemplate != nullptr)
|
||||
{
|
||||
for (i = 0; i < lcount; i++)
|
||||
{
|
||||
int position = '!' + i;
|
||||
|
@ -1049,6 +1068,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
|||
charMap.Insert(position, TexMan.GetTexture(lump));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filetemplate != nullptr)
|
||||
{
|
||||
TArray<FolderEntry> folderdata;
|
||||
|
@ -1061,7 +1081,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
|||
char *endp;
|
||||
auto base = ExtractFileBase(entry.name);
|
||||
auto position = strtoll(base.GetChars(), &endp, 16);
|
||||
if ((*endp == 0 || *endp == '.' && position >= '!' && position < 0xffff))
|
||||
if ((*endp == 0 || (*endp == '.' && position >= '!' && position < 0xffff)))
|
||||
{
|
||||
auto lump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch);
|
||||
if (lump.isValid())
|
||||
|
@ -1658,7 +1678,7 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump)
|
|||
else if (data[0] != 'F' || data[1] != 'O' || data[2] != 'N' ||
|
||||
(data[3] != '1' && data[3] != '2'))
|
||||
{
|
||||
I_FatalError ("%s is not a recognizable font", name);
|
||||
I_Error ("%s is not a recognizable font", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2942,7 +2962,7 @@ void V_InitFonts()
|
|||
V_InitCustomFonts ();
|
||||
|
||||
// load the heads-up font
|
||||
if (!(SmallFont = FFont::FindFont("SmallFont")))
|
||||
if (!(SmallFont = V_GetFont("SmallFont")))
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -2960,7 +2980,7 @@ void V_InitFonts()
|
|||
SmallFont = new FFont ("SmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1);
|
||||
}
|
||||
}
|
||||
if (!(SmallFont2 = FFont::FindFont("SmallFont2"))) // Only used by Strife
|
||||
if (!(SmallFont2 = V_GetFont("SmallFont2"))) // Only used by Strife
|
||||
{
|
||||
if (Wads.CheckNumForName ("STBFN033", ns_graphics) >= 0)
|
||||
{
|
||||
|
@ -2971,38 +2991,29 @@ void V_InitFonts()
|
|||
SmallFont2 = SmallFont;
|
||||
}
|
||||
}
|
||||
if (!(BigFont = FFont::FindFont("BigFont")))
|
||||
if (!(BigFont = V_GetFont("BigFont")))
|
||||
{
|
||||
int lump = Wads.CheckNumForName("BIGFONT");
|
||||
if (lump >= 0)
|
||||
const char *bigfontname = (gameinfo.gametype & GAME_DoomChex)? "DBIGFONT" : (gameinfo.gametype == GAME_Strife)? "SBIGFONT" : "HBIGFONT";
|
||||
try
|
||||
{
|
||||
BigFont = new FSingleLumpFont("BigFont", lump);
|
||||
BigFont = new FSingleLumpFont ("BigFont", Wads.CheckNumForName(bigfontname));
|
||||
}
|
||||
else if (gameinfo.gametype & GAME_DoomChex)
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
BigFont = new FSingleLumpFont ("BigFont", Wads.GetNumForName ("DBIGFONT"));
|
||||
}
|
||||
else if (gameinfo.gametype == GAME_Strife)
|
||||
{
|
||||
BigFont = new FSingleLumpFont ("BigFont", Wads.GetNumForName ("SBIGFONT"));
|
||||
}
|
||||
else
|
||||
{
|
||||
lump = Wads.CheckNumForName("HBIGFONT");
|
||||
if (lump >= 0)
|
||||
{
|
||||
BigFont = new FSingleLumpFont("BigFont", lump);
|
||||
}
|
||||
else
|
||||
{
|
||||
BigFont = new FFont ("BigFont", "FONTB%02u", "defbigfont", HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||
BigFont = new FFont ("BigFont", (gameinfo.gametype & GAME_Raven)? "FONTB%02u" : nullptr, "defbigfont", HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(ConFont = FFont::FindFont("ConsoleFont")))
|
||||
if (!(ConFont = V_GetFont("ConsoleFont")))
|
||||
{
|
||||
try
|
||||
{
|
||||
ConFont = new FSingleLumpFont ("ConsoleFont", Wads.GetNumForName ("CONFONT"));
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
ConFont = new FFont ("ConsoleFont", nullptr, "defbigfont", HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||
}
|
||||
}
|
||||
if (!(IntermissionFont = FFont::FindFont("IntermissionFont")))
|
||||
{
|
||||
if (gameinfo.gametype & GAME_DoomChex)
|
||||
|
|
Loading…
Reference in a new issue