mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Cleanup
This commit is contained in:
parent
a4e158b796
commit
1613fd76e2
@ -266,18 +266,6 @@ void CMeterString::Initialize()
|
|||||||
|
|
||||||
REAL size = (REAL)m_FontSize * (96.0f / (REAL)dpi);
|
REAL size = (REAL)m_FontSize * (96.0f / (REAL)dpi);
|
||||||
|
|
||||||
// Set font defaults
|
|
||||||
FontFamily defaultFamily(L"Arial");
|
|
||||||
Gdiplus::Font* defaultFont;
|
|
||||||
if (defaultFamily.IsAvailable())
|
|
||||||
{
|
|
||||||
defaultFont = new Gdiplus::Font(&defaultFamily, size, style);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
defaultFont = new Gdiplus::Font(FontFamily::GenericSansSerif(), size, style);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the font is in the cache and use it
|
// Check if the font is in the cache and use it
|
||||||
cacheKey += L'-';
|
cacheKey += L'-';
|
||||||
cacheKey += FontPropertiesToString(size, style);
|
cacheKey += FontPropertiesToString(size, style);
|
||||||
@ -287,27 +275,18 @@ void CMeterString::Initialize()
|
|||||||
m_Font = (*iter2).second;
|
m_Font = (*iter2).second;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
m_Font = NULL;
|
||||||
|
|
||||||
|
if (m_FontSize != 0)
|
||||||
{
|
{
|
||||||
if (m_FontFamily)
|
if (m_FontFamily)
|
||||||
{
|
{
|
||||||
m_Font = new Gdiplus::Font(m_FontFamily, size, style);
|
m_Font = new Gdiplus::Font(m_FontFamily, size, style);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Font = defaultFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status status = m_Font->GetLastStatus();
|
Status status = m_Font->GetLastStatus();
|
||||||
if (Ok == status)
|
|
||||||
{
|
|
||||||
// Cache
|
|
||||||
//LogWithArgs(LOG_DEBUG, L"FontCache-Add: %s", cacheKey.c_str());
|
|
||||||
c_Fonts[cacheKey] = m_Font;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Font = defaultFont;
|
|
||||||
|
|
||||||
|
if (Ok != status)
|
||||||
|
{
|
||||||
if (FontStyleNotFound == status)
|
if (FontStyleNotFound == status)
|
||||||
{
|
{
|
||||||
LogWithArgs(LOG_ERROR, L"Invalid StringStyle for font: %s", m_FontFace.c_str());
|
LogWithArgs(LOG_ERROR, L"Invalid StringStyle for font: %s", m_FontFace.c_str());
|
||||||
@ -316,12 +295,30 @@ void CMeterString::Initialize()
|
|||||||
{
|
{
|
||||||
LogWithArgs(LOG_ERROR, L"Invalid font: %s", m_FontFace.c_str());
|
LogWithArgs(LOG_ERROR, L"Invalid font: %s", m_FontFace.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete m_Font;
|
||||||
|
m_Font = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultFont != m_Font)
|
if (m_Font == NULL)
|
||||||
{
|
{
|
||||||
delete defaultFont;
|
// Use default font ("Arial" or GenericSansSerif)
|
||||||
|
m_Font = new Gdiplus::Font(L"Arial", size, style);
|
||||||
|
if (Ok != m_Font->GetLastStatus())
|
||||||
|
{
|
||||||
|
delete m_Font;
|
||||||
|
m_Font = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Font)
|
||||||
|
{
|
||||||
|
// Cache
|
||||||
|
//LogWithArgs(LOG_DEBUG, L"FontCache-Add: %s", cacheKey.c_str());
|
||||||
|
c_Fonts[cacheKey] = m_Font;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user