diff --git a/Common/Gfx/TextFormat.h b/Common/Gfx/TextFormat.h index cd490292..9926566e 100644 --- a/Common/Gfx/TextFormat.h +++ b/Common/Gfx/TextFormat.h @@ -20,6 +20,7 @@ #define RM_GFX_TEXTFORMAT_H_ #include +#include 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; diff --git a/Common/Gfx/TextFormatD2D.cpp b/Common/Gfx/TextFormatD2D.cpp index 357957ad..04d4d40c 100644 --- a/Common/Gfx/TextFormatD2D.cpp +++ b/Common/Gfx/TextFormatD2D.cpp @@ -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(); diff --git a/Common/Gfx/TextFormatD2D.h b/Common/Gfx/TextFormatD2D.h index a57b993e..55905d8e 100644 --- a/Common/Gfx/TextFormatD2D.h +++ b/Common/Gfx/TextFormatD2D.h @@ -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; diff --git a/Common/Gfx/TextFormatGDIP.cpp b/Common/Gfx/TextFormatGDIP.cpp index 538e0350..3f0d7bc1 100644 --- a/Common/Gfx/TextFormatGDIP.cpp +++ b/Common/Gfx/TextFormatGDIP.cpp @@ -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; diff --git a/Common/Gfx/TextFormatGDIP.h b/Common/Gfx/TextFormatGDIP.h index df2d44b2..a9e25fe2 100644 --- a/Common/Gfx/TextFormatGDIP.h +++ b/Common/Gfx/TextFormatGDIP.h @@ -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; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index fe1b4011..efbe0bc8 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -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()); } /* diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index e998a0e1..bad036c0 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -257,7 +257,6 @@ void CMeterWindow::Dispose(bool refresh) if (m_FontCollection) { - CMeterString::FreeFontCache(m_FontCollection); delete m_FontCollection; m_FontCollection = NULL; }