mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code cleanup.
This commit is contained in:
parent
f22324d423
commit
84dba0c65a
@ -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());
|
int i = 2;
|
||||||
|
do
|
||||||
// It wasn't found in the fonts folder, check the local folder
|
|
||||||
if(nResults != Ok)
|
|
||||||
{
|
{
|
||||||
szFontFile = m_SkinPath; // Get the local path
|
// We want to check the fonts folder first
|
||||||
szFontFile += m_SkinName;
|
// !!!!!!! - We may want to fix the method in which I get the path to
|
||||||
szFontFile += L"\\";
|
// Rainmeter/fonts
|
||||||
|
std::wstring szFontFile = m_Rainmeter->GetPath() + L"Fonts\\";
|
||||||
szFontFile += localFont;
|
szFontFile += localFont;
|
||||||
|
Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||||
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
|
||||||
|
|
||||||
// The font wasn't found, check full path.
|
// It wasn't found in the fonts folder, check the local folder
|
||||||
if(nResults != Ok)
|
if(nResults != Ok)
|
||||||
{
|
{
|
||||||
szFontFile = localFont;
|
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());
|
||||||
|
|
||||||
|
// The font wasn't found, check full path.
|
||||||
if(nResults != Ok)
|
if(nResults != Ok)
|
||||||
{
|
{
|
||||||
std::wstring error = L"Couldn't load font file: " + localFont;
|
szFontFile = localFont;
|
||||||
Log(LOG_ERROR, error.c_str());
|
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||||
|
|
||||||
|
if(nResults != Ok)
|
||||||
|
{
|
||||||
|
std::wstring error = L"Unable to load font file: " + localFont;
|
||||||
|
Log(LOG_ERROR, error.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// Here we are checking to see if there are more than one local font
|
||||||
// Here we are checking to see if there are more than one local font
|
// to be loaded. They will be named LocalFont2, LocalFont3, etc.
|
||||||
// to be loaded. They will be named LocalFont2, LocalFont3, etc.
|
WCHAR tmpName[64];
|
||||||
WCHAR tmpName[64];
|
_snwprintf_s(tmpName, _TRUNCATE, L"LocalFont%i", i++);
|
||||||
int i = 2;
|
|
||||||
bool loop = true;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
_snwprintf_s(tmpName, _TRUNCATE, L"LocalFont%i", i);
|
|
||||||
localFont = m_Parser.ReadString(L"Rainmeter", tmpName, L"");
|
localFont = m_Parser.ReadString(L"Rainmeter", tmpName, L"");
|
||||||
// There is a key called LocalFont%i
|
|
||||||
if (!localFont.empty())
|
} while (!localFont.empty());
|
||||||
{
|
|
||||||
// We want to check the fonts folder first
|
|
||||||
// !!!!!!! - 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;
|
|
||||||
|
|
||||||
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 += 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());
|
|
||||||
// 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
|
|
||||||
{
|
|
||||||
loop = false;
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
} while(loop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the meters and measures
|
// Create the meters and measures
|
||||||
|
Loading…
Reference in New Issue
Block a user