mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 17:41:19 +00:00
- changed font loader to detect fonts in folders and to find all default fonts in folders.
# Conflicts: # src/v_font.cpp
This commit is contained in:
parent
32c24038b0
commit
1edf0a001b
1 changed files with 68 additions and 57 deletions
|
@ -1059,10 +1059,22 @@ FFont *V_GetFont(const char *name)
|
||||||
if (font == NULL)
|
if (font == NULL)
|
||||||
{
|
{
|
||||||
int lump = -1;
|
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);
|
lump = Wads.CheckNumForFullName(name, true);
|
||||||
|
|
||||||
if (lump != -1)
|
if (lump != -1 && Wads.GetLumpFile(lump) >= folderfile)
|
||||||
{
|
{
|
||||||
uint32_t head;
|
uint32_t head;
|
||||||
{
|
{
|
||||||
|
@ -1072,19 +1084,24 @@ FFont *V_GetFont(const char *name)
|
||||||
if ((head & MAKE_ID(255,255,255,0)) == MAKE_ID('F','O','N',0) ||
|
if ((head & MAKE_ID(255,255,255,0)) == MAKE_ID('F','O','N',0) ||
|
||||||
head == MAKE_ID(0xE1,0xE6,0xD5,0x1A))
|
head == MAKE_ID(0xE1,0xE6,0xD5,0x1A))
|
||||||
{
|
{
|
||||||
font = new FSingleLumpFont (name, lump);
|
return new FSingleLumpFont (name, lump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (font == NULL)
|
|
||||||
{
|
|
||||||
FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any);
|
FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any);
|
||||||
if (picnum.isValid())
|
if (picnum.isValid())
|
||||||
{
|
{
|
||||||
font = new FSinglePicFont (name);
|
FTexture *tex = TexMan[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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1119,6 +1136,8 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
||||||
TMap<int, FTexture*> charMap;
|
TMap<int, FTexture*> charMap;
|
||||||
int minchar = INT_MAX;
|
int minchar = INT_MAX;
|
||||||
int maxchar = INT_MIN;
|
int maxchar = INT_MIN;
|
||||||
|
if (nametemplate != nullptr)
|
||||||
|
{
|
||||||
for (i = 0; i < lcount; i++)
|
for (i = 0; i < lcount; i++)
|
||||||
{
|
{
|
||||||
int position = '!' + i;
|
int position = '!' + i;
|
||||||
|
@ -1145,6 +1164,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
||||||
charMap.Insert(position, TexMan[lump]);
|
charMap.Insert(position, TexMan[lump]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (filetemplate != nullptr)
|
if (filetemplate != nullptr)
|
||||||
{
|
{
|
||||||
TArray<FolderEntry> folderdata;
|
TArray<FolderEntry> folderdata;
|
||||||
|
@ -1157,7 +1177,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
||||||
char *endp;
|
char *endp;
|
||||||
auto base = ExtractFileBase(entry.name);
|
auto base = ExtractFileBase(entry.name);
|
||||||
auto position = strtoll(base.GetChars(), &endp, 16);
|
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);
|
auto lump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch);
|
||||||
if (lump.isValid())
|
if (lump.isValid())
|
||||||
|
@ -1838,7 +1858,7 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump)
|
||||||
else if (data[0] != 'F' || data[1] != 'O' || data[2] != 'N' ||
|
else if (data[0] != 'F' || data[1] != 'O' || data[2] != 'N' ||
|
||||||
(data[3] != '1' && data[3] != '2'))
|
(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
|
else
|
||||||
{
|
{
|
||||||
|
@ -3492,7 +3512,7 @@ void V_InitFonts()
|
||||||
V_InitCustomFonts ();
|
V_InitCustomFonts ();
|
||||||
|
|
||||||
// load the heads-up font
|
// load the heads-up font
|
||||||
if (!(SmallFont = FFont::FindFont("SmallFont")))
|
if (!(SmallFont = V_GetFont("SmallFont")))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -3510,7 +3530,7 @@ void V_InitFonts()
|
||||||
SmallFont = new FFont ("SmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1);
|
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)
|
if (Wads.CheckNumForName ("STBFN033", ns_graphics) >= 0)
|
||||||
{
|
{
|
||||||
|
@ -3521,38 +3541,29 @@ void V_InitFonts()
|
||||||
SmallFont2 = SmallFont;
|
SmallFont2 = SmallFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(BigFont = FFont::FindFont("BigFont")))
|
if (!(BigFont = V_GetFont("BigFont")))
|
||||||
{
|
{
|
||||||
int lump = Wads.CheckNumForName("BIGFONT");
|
const char *bigfontname = (gameinfo.gametype & GAME_DoomChex)? "DBIGFONT" : (gameinfo.gametype == GAME_Strife)? "SBIGFONT" : "HBIGFONT";
|
||||||
if (lump >= 0)
|
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"));
|
BigFont = new FFont ("BigFont", (gameinfo.gametype & GAME_Raven)? "FONTB%02u" : nullptr, "defbigfont", HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!(ConFont = V_GetFont("ConsoleFont")))
|
||||||
if (!(ConFont = FFont::FindFont("ConsoleFont")))
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
ConFont = new FSingleLumpFont ("ConsoleFont", Wads.GetNumForName ("CONFONT"));
|
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 (!(IntermissionFont = FFont::FindFont("IntermissionFont")))
|
||||||
{
|
{
|
||||||
if (gameinfo.gametype & GAME_DoomChex)
|
if (gameinfo.gametype & GAME_DoomChex)
|
||||||
|
|
Loading…
Reference in a new issue