Gfx: Add FontCollection implementation

The D2D implementation is a stub for now.
This commit is contained in:
Birunthan Mohanathas
2013-04-09 20:35:49 +03:00
parent 4d22c5ac61
commit 0b3a4d86c4
19 changed files with 353 additions and 41 deletions

View File

@ -68,6 +68,9 @@
<ClCompile Include="..\Common\Gfx\Canvas.cpp" />
<ClCompile Include="..\Common\Gfx\CanvasD2D.cpp" />
<ClCompile Include="..\Common\Gfx\CanvasGDIP.cpp" />
<ClCompile Include="..\Common\Gfx\FontCollection.cpp" />
<ClCompile Include="..\Common\Gfx\FontCollectionD2D.cpp" />
<ClCompile Include="..\Common\Gfx\FontCollectionGDIP.cpp" />
<ClCompile Include="..\Common\Gfx\TextFormat.cpp" />
<ClCompile Include="..\Common\Gfx\TextFormatD2D.cpp" />
<ClCompile Include="..\Common\Gfx\TextFormatGDIP.cpp" />
@ -287,6 +290,9 @@
<ClInclude Include="..\Common\Gfx\Canvas.h" />
<ClInclude Include="..\Common\Gfx\CanvasD2D.h" />
<ClInclude Include="..\Common\Gfx\CanvasGDIP.h" />
<ClInclude Include="..\Common\Gfx\FontCollection.h" />
<ClInclude Include="..\Common\Gfx\FontCollectionD2D.h" />
<ClInclude Include="..\Common\Gfx\FontCollectionGDIP.h" />
<ClInclude Include="..\Common\Gfx\TextFormat.h" />
<ClInclude Include="..\Common\Gfx\TextFormatD2D.h" />
<ClInclude Include="..\Common\Gfx\TextFormatGDIP.h" />

View File

@ -342,9 +342,24 @@
<ClCompile Include="..\Common\StringUtil.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\Canvas.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\CanvasD2D.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\CanvasGDIP.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\FontCollection.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\FontCollectionD2D.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\FontCollectionGDIP.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\TextFormat.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
@ -354,21 +369,15 @@
<ClCompile Include="..\Common\Gfx\TextFormatGDIP.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\WICBitmapLockGDIP.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\Canvas.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\CanvasD2D.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\WICBitmapDIB.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\WICBitmapLockDIB.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
<ClCompile Include="..\Common\Gfx\WICBitmapLockGDIP.cpp">
<Filter>Common\Gfx</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ConfigParser.h">
@ -614,9 +623,24 @@
<ClInclude Include="..\Common\StringUtil.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\Canvas.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\CanvasD2D.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\CanvasGDIP.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\FontCollectionGDIP.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\FontCollection.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\FontCollectionD2D.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\TextFormat.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
@ -626,21 +650,15 @@
<ClInclude Include="..\Common\Gfx\TextFormatGDIP.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\WICBitmapLockGDIP.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\Canvas.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\CanvasD2D.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\WICBitmapDIB.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\WICBitmapLockDIB.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
<ClInclude Include="..\Common\Gfx\WICBitmapLockGDIP.h">
<Filter>Common\Gfx</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Library.rc">

View File

@ -157,7 +157,7 @@ void CMeterString::Initialize()
m_FontSize,
m_Style & BOLD,
m_Style & ITALIC,
m_MeterWindow->GetPrivateFontCollection());
m_MeterWindow->GetFontCollection());
}
/*

View File

@ -2096,7 +2096,7 @@ bool CMeterWindow::ReadSkin()
if (find != INVALID_HANDLE_VALUE)
{
m_FontCollection = new PrivateFontCollection();
m_FontCollection = m_Canvas->CreateFontCollection();
do
{
@ -2104,8 +2104,7 @@ bool CMeterWindow::ReadSkin()
{
std::wstring file(resourcePath, 0, resourcePath.length() - 1);
file += fd.cFileName;
Status status = m_FontCollection->AddFontFile(file.c_str());
if (status != Ok)
if (!m_FontCollection->AddFile(file.c_str()))
{
std::wstring error = L"Unable to load font: ";
error += file.c_str();
@ -2125,7 +2124,7 @@ bool CMeterWindow::ReadSkin()
{
if (!m_FontCollection)
{
m_FontCollection = new PrivateFontCollection();
m_FontCollection = m_Canvas->CreateFontCollection();
}
int i = 1;
@ -2134,13 +2133,11 @@ bool CMeterWindow::ReadSkin()
// Try program folder first
std::wstring szFontFile = Rainmeter->GetPath() + L"Fonts\\";
szFontFile += localFont;
Status status = m_FontCollection->AddFontFile(szFontFile.c_str());
if (status != Ok)
if (!m_FontCollection->AddFile(szFontFile.c_str()))
{
szFontFile = localFont;
MakePathAbsolute(szFontFile);
status = m_FontCollection->AddFontFile(szFontFile.c_str());
if (status != Ok)
if (!m_FontCollection->AddFile(szFontFile.c_str()))
{
std::wstring error = L"Unable to load font: ";
error += localFont;

View File

@ -152,11 +152,10 @@ class CMeasure;
class CMeter;
namespace Gfx {
class Canvas;
class FontCollection;
class TextFormat;
} // namespace Gfx
}
class CMeterWindow : public CGroup
{
@ -249,7 +248,7 @@ public:
void MakePathAbsolute(std::wstring& path);
Gdiplus::PrivateFontCollection* GetPrivateFontCollection() { return m_FontCollection; }
Gfx::FontCollection* GetFontCollection() { return m_FontCollection; }
CMeter* GetMeter(const std::wstring& meterName);
CMeasure* GetMeasure(const std::wstring& measureName) { return m_Parser.GetMeasure(measureName); }
@ -460,7 +459,7 @@ private:
int m_UpdateCounter;
UINT m_MouseMoveCounter;
Gdiplus::PrivateFontCollection* m_FontCollection;
Gfx::FontCollection* m_FontCollection;
bool m_ToolTipHidden;