This commit is contained in:
spx 2012-09-26 18:47:25 -07:00
parent a4e158b796
commit 1613fd76e2

View File

@ -266,18 +266,6 @@ void CMeterString::Initialize()
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
cacheKey += L'-';
cacheKey += FontPropertiesToString(size, style);
@ -287,27 +275,18 @@ void CMeterString::Initialize()
m_Font = (*iter2).second;
}
else
{
m_Font = NULL;
if (m_FontSize != 0)
{
if (m_FontFamily)
{
m_Font = new Gdiplus::Font(m_FontFamily, size, style);
}
else
{
m_Font = defaultFont;
}
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)
{
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());
}
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;
}
}
}
}