Gfx: Tweaks

This commit is contained in:
Birunthan Mohanathas 2013-04-08 17:29:26 +03:00
parent 53c6966819
commit 7c90f65659
2 changed files with 16 additions and 15 deletions

View File

@ -101,7 +101,7 @@ void TextFormatD2D::SetProperties(const WCHAR* fontFamily, int size, bool bold,
if (dwFont)
{
WCHAR buffer[LF_FACESIZE];
if (GetDWFontFamilyName(dwFont, buffer, _countof(buffer)))
if (GetFamilyNameFromDWFont(dwFont, buffer, _countof(buffer)))
{
// TODO: If |fontFamily| is e.g. 'Segoe UI Semibold' and |bold| is true, we might want
// to make the weight heaver to match GDI+.
@ -222,15 +222,18 @@ IDWriteFont* TextFormatD2D::CreateDWFontFromGDIFamilyName(const WCHAR* fontFamil
return nullptr;
}
bool TextFormatD2D::GetDWFontFamilyName(IDWriteFont* font, WCHAR* buffer, const UINT bufferSize)
bool TextFormatD2D::GetFamilyNameFromDWFont(IDWriteFont* font, WCHAR* buffer, const UINT bufferSize)
{
bool result = false;
IDWriteFontFamily* dwFontFamily;
HRESULT hr = font->GetFontFamily(&dwFontFamily);
if (SUCCEEDED(hr))
{
return SUCCEEDED(hr) ? GetFamilyNameFromDWFontFamily(dwFontFamily, buffer, bufferSize) : false;
}
bool TextFormatD2D::GetFamilyNameFromDWFontFamily(IDWriteFontFamily* fontFamily, WCHAR* buffer, const UINT bufferSize)
{
bool result = false;
IDWriteLocalizedStrings* dwFamilyNames;
hr = dwFontFamily->GetFamilyNames(&dwFamilyNames);
HRESULT hr = fontFamily->GetFamilyNames(&dwFamilyNames);
if (SUCCEEDED(hr))
{
// TODO: Determine the best index?
@ -239,9 +242,6 @@ bool TextFormatD2D::GetDWFontFamilyName(IDWriteFont* font, WCHAR* buffer, const
dwFamilyNames->Release();
}
dwFontFamily->Release();
}
return result;
}

View File

@ -56,7 +56,8 @@ private:
// style.
static IDWriteFont* CreateDWFontFromGDIFamilyName(const WCHAR* fontFamily, bool bold, bool italic);
static bool GetDWFontFamilyName(IDWriteFont* font, WCHAR* buffer, UINT bufferSize);
static bool GetFamilyNameFromDWFont(IDWriteFont* font, WCHAR* buffer, UINT bufferSize);
static bool GetFamilyNameFromDWFontFamily(IDWriteFontFamily* fontFamily, WCHAR* buffer, UINT bufferSize);
IDWriteTextFormat* m_TextFormat;
IDWriteTextLayout* m_TextLayout;