mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Add temporary solution for local fonts
This commit is contained in:
parent
056277ce4f
commit
39fe9750fd
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -257,7 +257,6 @@ void CMeterWindow::Dispose(bool refresh)
|
||||
|
||||
if (m_FontCollection)
|
||||
{
|
||||
CMeterString::FreeFontCache(m_FontCollection);
|
||||
delete m_FontCollection;
|
||||
m_FontCollection = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user