simplifications and minor fixes
This commit is contained in:
+7
-21
@@ -345,30 +345,14 @@ void Font::SetDefaultGlyph(FontPage *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* "Normal.png", "Normal [foo].png", "Normal 16x16.png", and "Normal [foo] 16x16.png"
|
CString Font::GetFontName(CString FileName)
|
||||||
* are all part of the FontName "Normal". "Normal2 16x16.png" is not.
|
|
||||||
*
|
|
||||||
* So, FileName must start with FontName, followed by either " [", " DIGIT" or
|
|
||||||
* a period.
|
|
||||||
*
|
|
||||||
* This is to make sure we don't pull in textures from similarly-named fonts.
|
|
||||||
*/
|
|
||||||
bool Font::MatchesFont(CString FontName, CString FileName)
|
|
||||||
{
|
|
||||||
FontName.MakeLower();
|
|
||||||
FileName.MakeLower();
|
|
||||||
|
|
||||||
if(FileName.substr(0, FontName.size()) != FontName)
|
|
||||||
return false;
|
|
||||||
FileName = FileName.substr(FontName.size());
|
|
||||||
|
|
||||||
return regex("^( \\[|\\.| [0-9]+x[0-9]+)", FileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
CString GetFontName(CString FileName)
|
|
||||||
{
|
{
|
||||||
CString orig = FileName;
|
CString orig = FileName;
|
||||||
|
|
||||||
|
CString sDir, sFName, sExt;
|
||||||
|
splitpath( FileName, sDir, sFName, sExt );
|
||||||
|
FileName = sFName;
|
||||||
|
|
||||||
/* If it ends in an extension, remove it. */
|
/* If it ends in an extension, remove it. */
|
||||||
if(regex("\\....", FileName))
|
if(regex("\\....", FileName))
|
||||||
FileName.erase(FileName.size()-4);
|
FileName.erase(FileName.size()-4);
|
||||||
@@ -387,9 +371,11 @@ CString GetFontName(CString FileName)
|
|||||||
if(FileName.empty())
|
if(FileName.empty())
|
||||||
RageException::Throw("Can't parse font filename \"%s\"", orig.GetString());
|
RageException::Throw("Can't parse font filename \"%s\"", orig.GetString());
|
||||||
|
|
||||||
|
FileName.MakeLower();
|
||||||
return FileName;
|
return FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Given a file in a font, find all of the files for the font.
|
/* Given a file in a font, find all of the files for the font.
|
||||||
*
|
*
|
||||||
* Possibilities:
|
* Possibilities:
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public:
|
|||||||
|
|
||||||
static const longchar DEFAULT_GLYPH;
|
static const longchar DEFAULT_GLYPH;
|
||||||
|
|
||||||
static bool MatchesFont(CString FontName, CString FileName);
|
static CString GetFontName(CString FileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* List of pages and fonts that we use (and are responsible for freeing). */
|
/* List of pages and fonts that we use (and are responsible for freeing). */
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ public:
|
|||||||
* adjustment of fonts in ScreenTestFonts at the moment. */
|
* adjustment of fonts in ScreenTestFonts at the moment. */
|
||||||
void ReloadFonts();
|
void ReloadFonts();
|
||||||
|
|
||||||
/* Return true if FileName is a part of the font "FontName". */
|
|
||||||
static bool MatchesFont(CString FontName, CString FileName);
|
|
||||||
|
|
||||||
static longchar MakeGameGlyph(longchar c, Game g);
|
static longchar MakeGameGlyph(longchar c, Game g);
|
||||||
static bool ExtractGameGlyph(longchar ch, int &c, Game &g);
|
static bool ExtractGameGlyph(longchar ch, int &c, Game &g);
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ void splitpath( CString Path, CString& Dir, CString& Filename, CString& Ext )
|
|||||||
Dir = mat[0];
|
Dir = mat[0];
|
||||||
Path = mat[1];
|
Path = mat[1];
|
||||||
|
|
||||||
if(regex("^(.*)(\\....)$", Path, mat))
|
if(regex("^(.*)(\\.[^\\.]+)$", Path, mat))
|
||||||
{
|
{
|
||||||
Filename = mat[0];
|
Filename = mat[0];
|
||||||
Ext = mat[1];
|
Ext = mat[1];
|
||||||
|
|||||||
@@ -129,44 +129,30 @@ try_element_again:
|
|||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Search both the current theme and the default theme dirs for this element
|
// Search both the current theme and the default theme dirs for this element
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
static const char *font_masks[] = { "*.png", ".redir", NULL };
|
|
||||||
static const char *blank_mask[] = { "", NULL };
|
|
||||||
const char **asset_masks = font_masks;
|
|
||||||
|
|
||||||
/* If the theme asset name has an extension, don't add
|
CString path = sCurrentThemeDir;
|
||||||
* a mask. This should only happen with redirs. */
|
GetDirListing( sCurrentThemeDir + "Fonts\\"+sFileName + "*",
|
||||||
if(sFileName.find_last_of('.') != sFileName.npos)
|
asPossibleElementFilePaths, false, true );
|
||||||
asset_masks = blank_mask;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
CString path;
|
|
||||||
|
|
||||||
for(i = 0; asset_masks[i]; ++i)
|
|
||||||
{
|
|
||||||
path = sCurrentThemeDir;
|
|
||||||
GetDirListing( path + "Fonts\\"+sFileName + asset_masks[i],
|
|
||||||
asPossibleElementFilePaths, false, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Weed out false matches. (For example, this gets rid of "normal2" when
|
/* Weed out false matches. (For example, this gets rid of "normal2" when
|
||||||
* we're really looking for "normal".) */
|
* we're really looking for "normal".) */
|
||||||
|
int i;
|
||||||
for(i = 0; i < int(asPossibleElementFilePaths.size()); ) {
|
for(i = 0; i < int(asPossibleElementFilePaths.size()); ) {
|
||||||
if(!Font::MatchesFont(path + "Fonts\\"+ sFileName, asPossibleElementFilePaths[i]))
|
if(Font::GetFontName(sFileName) != Font::GetFontName(asPossibleElementFilePaths[i]))
|
||||||
asPossibleElementFilePaths.erase(asPossibleElementFilePaths.begin()+i);
|
asPossibleElementFilePaths.erase(asPossibleElementFilePaths.begin()+i);
|
||||||
else i++;
|
else i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(asPossibleElementFilePaths.empty())
|
if(asPossibleElementFilePaths.empty())
|
||||||
for(i = 0; asset_masks[i]; ++i)
|
|
||||||
{
|
{
|
||||||
path = sDefaultThemeDir;
|
path = sDefaultThemeDir;
|
||||||
|
|
||||||
GetDirListing( path + "Fonts\\"+ sFileName + asset_masks[i],
|
GetDirListing( sDefaultThemeDir + "Fonts\\"+ sFileName + "*",
|
||||||
asPossibleElementFilePaths, false, true );
|
asPossibleElementFilePaths, false, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < int(asPossibleElementFilePaths.size()); ) {
|
for(i = 0; i < int(asPossibleElementFilePaths.size()); ) {
|
||||||
if(!Font::MatchesFont(path + "Fonts\\"+ sFileName, asPossibleElementFilePaths[i]))
|
if(Font::GetFontName(sFileName) != Font::GetFontName(asPossibleElementFilePaths[i]))
|
||||||
asPossibleElementFilePaths.erase(asPossibleElementFilePaths.begin()+i);
|
asPossibleElementFilePaths.erase(asPossibleElementFilePaths.begin()+i);
|
||||||
else i++;
|
else i++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user