From 0f6f6d48e58d0eb5232e2f07fd2f9b49dd58df6c Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 5 May 2013 17:34:22 +0300 Subject: [PATCH] Gfx: Minor fixes --- Common/Gfx/Util/DWriteHelpers.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Common/Gfx/Util/DWriteHelpers.cpp b/Common/Gfx/Util/DWriteHelpers.cpp index 491f0f2a..a93d6377 100644 --- a/Common/Gfx/Util/DWriteHelpers.cpp +++ b/Common/Gfx/Util/DWriteHelpers.cpp @@ -17,6 +17,7 @@ */ #include "DWriteHelpers.h" +#include namespace Gfx { namespace Util { @@ -76,8 +77,8 @@ void GetPropertiesFromDWriteFont( IDWriteFont* CreateDWriteFontFromGDIFamilyName(IDWriteFactory* factory, const WCHAR* gdiFamilyName) { - IDWriteGdiInterop* dwGdiInterop; - HRESULT hr = factory->GetGdiInterop(&dwGdiInterop); + Microsoft::WRL::ComPtr dwGdiInterop; + HRESULT hr = factory->GetGdiInterop(dwGdiInterop.GetAddressOf()); if (SUCCEEDED(hr)) { LOGFONT lf = {}; @@ -96,8 +97,6 @@ IDWriteFont* CreateDWriteFontFromGDIFamilyName(IDWriteFactory* factory, const WC { return dwFont; } - - dwGdiInterop->Release(); } return nullptr; @@ -155,25 +154,16 @@ bool IsFamilyInSystemFontCollection(IDWriteFactory* factory, const WCHAR* family HRESULT GetGDIFamilyNameFromDWriteFont(IDWriteFont* font, WCHAR* buffer, UINT bufferSize) { - IDWriteLocalizedStrings* strings; + Microsoft::WRL::ComPtr strings; BOOL stringsExist; - HRESULT hr = font->GetInformationalStrings( - DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &stringsExist); - if (SUCCEEDED(hr)) + font->GetInformationalStrings( + DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, strings.GetAddressOf(), &stringsExist); + if (strings && stringsExist) { - if (stringsExist) - { - hr = strings->GetString(0, buffer, bufferSize); - } - else - { - hr = E_FAIL; - } - - strings->Release(); + return strings->GetString(0, buffer, bufferSize); } - return hr; + return E_FAIL; } IDWriteFont* FindDWriteFontInFontFamilyByGDIFamilyName(