Code cleanup.

This commit is contained in:
spx 2011-01-23 06:16:18 +00:00
parent f22324d423
commit 84dba0c65a

View File

@ -1897,88 +1897,48 @@ bool CMeterWindow::ReadSkin()
// If there is a local font we want to load it // If there is a local font we want to load it
if(!localFont.empty()) if(!localFont.empty())
{ {
// We want to check the fonts folder first m_FontCollection = new PrivateFontCollection();
// !!!!!!! - We may want to fix the method in which I get the path to
// Rainmeter/fonts
std::wstring szFontFile = m_Rainmeter->GetPath();
m_FontCollection = new Gdiplus::PrivateFontCollection();
Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// It wasn't found in the fonts folder, check the local folder
if(nResults != Ok)
{
szFontFile = m_SkinPath; // Get the local path
szFontFile += m_SkinName;
szFontFile += L"\\";
szFontFile += localFont;
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// The font wasn't found, check full path.
if(nResults != Ok)
{
szFontFile = localFont;
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
if(nResults != Ok)
{
std::wstring error = L"Couldn't load font file: " + localFont;
Log(LOG_ERROR, error.c_str());
}
}
}
// Here we are checking to see if there are more than one local font
// to be loaded. They will be named LocalFont2, LocalFont3, etc.
WCHAR tmpName[64];
int i = 2; int i = 2;
bool loop = true;
do do
{ {
_snwprintf_s(tmpName, _TRUNCATE, L"LocalFont%i", i); // We want to check the fonts folder first
localFont = m_Parser.ReadString(L"Rainmeter", tmpName, L""); // !!!!!!! - We may want to fix the method in which I get the path to
// There is a key called LocalFont%i // Rainmeter/fonts
if (!localFont.empty()) std::wstring szFontFile = m_Rainmeter->GetPath() + L"Fonts\\";
{ szFontFile += localFont;
// We want to check the fonts folder first Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// !!!!!!! - We may want to fix the method in which I get the path to
// Rainmeter/fonts
std::wstring szFontFile = m_Rainmeter->GetPath();
szFontFile += L"Fonts\\";
szFontFile += localFont;
// It wasn't found in the fonts folder, check the local folder
if(nResults != Ok)
{
szFontFile = m_SkinPath; // Get the local path
szFontFile += m_SkinName;
szFontFile += L"\\";
szFontFile += localFont;
nResults = m_FontCollection->AddFontFile(szFontFile.c_str()); nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// It wasn't found in the fonts folder, check the local folder // The font wasn't found, check full path.
if(nResults != Ok) if(nResults != Ok)
{ {
szFontFile = m_SkinPath; // Get the local path szFontFile = localFont;
szFontFile += m_SkinName;
szFontFile += localFont;
nResults = m_FontCollection->AddFontFile(szFontFile.c_str()); nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// The font wasn't found, check full path.
if(nResults != Ok) if(nResults != Ok)
{ {
szFontFile = localFont; std::wstring error = L"Unable to load font file: " + localFont;
nResults = m_FontCollection->AddFontFile(szFontFile.c_str()); Log(LOG_ERROR, error.c_str());
// The font file wasn't found anywhere, log the error
if(nResults != Ok)
{
std::wstring error = L"Couldn't load font file: " + localFont;
Log(LOG_ERROR, error.c_str());
}
} }
} }
} }
// There were no extra Local Fonts found: exit loop.
else // Here we are checking to see if there are more than one local font
{ // to be loaded. They will be named LocalFont2, LocalFont3, etc.
loop = false; WCHAR tmpName[64];
} _snwprintf_s(tmpName, _TRUNCATE, L"LocalFont%i", i++);
++i; localFont = m_Parser.ReadString(L"Rainmeter", tmpName, L"");
} while(loop);
} while (!localFont.empty());
} }
// Create the meters and measures // Create the meters and measures