Gfx: Add temporary solution for local fonts

This commit is contained in:
Birunthan Mohanathas 2013-03-28 15:09:46 +02:00
parent 056277ce4f
commit 39fe9750fd
7 changed files with 19 additions and 7 deletions

View File

@ -20,6 +20,7 @@
#define RM_GFX_TEXTFORMAT_H_
#include <Windows.h>
#include <GdiPlus.h>
namespace Gfx {
@ -43,7 +44,7 @@ public:
virtual ~TextFormat();
virtual bool IsInitialized() = 0;
virtual void SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic) = 0;
virtual void SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic, Gdiplus::PrivateFontCollection* fontCollection) = 0;
virtual void SetTrimming(bool trim) = 0;

View File

@ -47,7 +47,7 @@ void TextFormatD2D::Dispose()
}
}
void TextFormatD2D::SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic)
void TextFormatD2D::SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic, Gdiplus::PrivateFontCollection* fontCollection)
{
Dispose();

View File

@ -31,7 +31,7 @@ public:
virtual ~TextFormatD2D();
virtual bool IsInitialized() { return m_TextFormat != nullptr; }
virtual void SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic);
virtual void SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic, Gdiplus::PrivateFontCollection* fontCollection) override;
virtual void SetTrimming(bool trim) override;
virtual void SetHorizontalAlignment(HorizontalAlignment alignment) override;

View File

@ -40,7 +40,7 @@ void TextFormatGDIP::Dispose()
m_Font = nullptr;
}
void TextFormatGDIP::SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic)
void TextFormatGDIP::SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic, Gdiplus::PrivateFontCollection* fontCollection)
{
Dispose();
@ -49,6 +49,17 @@ void TextFormatGDIP::SetProperties(const WCHAR* fontFamily, int size, bool bold,
{
delete m_FontFamily;
m_FontFamily = nullptr;
// Not found in system collection so try the private collection.
if (fontCollection)
{
m_FontFamily = new Gdiplus::FontFamily(fontFamily, fontCollection);
if (m_FontFamily->GetLastStatus() != Gdiplus::Ok)
{
delete m_FontFamily;
m_FontFamily = nullptr;
}
}
}
Gdiplus::FontStyle style = Gdiplus::FontStyleRegular;

View File

@ -31,7 +31,7 @@ public:
virtual ~TextFormatGDIP();
virtual bool IsInitialized() { return m_Font != nullptr; }
virtual void SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic);
virtual void SetProperties(const WCHAR* fontFamily, int size, bool bold, bool italic, Gdiplus::PrivateFontCollection* fontCollection) override;
virtual void SetTrimming(bool trim) override;
virtual void SetHorizontalAlignment(HorizontalAlignment alignment) override;

View File

@ -156,7 +156,8 @@ void CMeterString::Initialize()
m_FontFace.c_str(),
m_FontSize,
m_Style & BOLD,
m_Style & ITALIC);
m_Style & ITALIC,
m_MeterWindow->GetPrivateFontCollection());
}
/*

View File

@ -257,7 +257,6 @@ void CMeterWindow::Dispose(bool refresh)
if (m_FontCollection)
{
CMeterString::FreeFontCache(m_FontCollection);
delete m_FontCollection;
m_FontCollection = NULL;
}