mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Check for errors in TextFormatD2D::SetProperties
This commit is contained in:
parent
2e2ced7403
commit
34abccc29b
@ -37,6 +37,9 @@ void TextFormatD2D::Dispose()
|
|||||||
m_TextFormat.Reset();
|
m_TextFormat.Reset();
|
||||||
m_TextLayout.Reset();
|
m_TextLayout.Reset();
|
||||||
m_InlineEllipsis.Reset();
|
m_InlineEllipsis.Reset();
|
||||||
|
|
||||||
|
m_ExtraHeight = 0.0f;
|
||||||
|
m_LineGap = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFormatD2D::CreateLayout(
|
void TextFormatD2D::CreateLayout(
|
||||||
@ -160,23 +163,28 @@ void TextFormatD2D::SetProperties(
|
|||||||
SetHorizontalAlignment(GetHorizontalAlignment());
|
SetHorizontalAlignment(GetHorizontalAlignment());
|
||||||
SetVerticalAlignment(GetVerticalAlignment());
|
SetVerticalAlignment(GetVerticalAlignment());
|
||||||
|
|
||||||
// TODO: Clean this up and check for errors.
|
// Get the family name to in case CreateTextFormat() fallbacked on some other family name.
|
||||||
Microsoft::WRL::ComPtr<IDWriteFontCollection> collection;
|
hr = m_TextFormat->GetFontFamilyName(dwriteFamilyName, _countof(dwriteFamilyName));
|
||||||
m_TextFormat->GetFontCollection(collection.GetAddressOf());
|
if (FAILED(hr)) return;
|
||||||
|
|
||||||
|
Microsoft::WRL::ComPtr<IDWriteFontCollection> collection;
|
||||||
|
Microsoft::WRL::ComPtr<IDWriteFontFamily> fontFamily;
|
||||||
UINT32 familyNameIndex;
|
UINT32 familyNameIndex;
|
||||||
BOOL exists;
|
BOOL exists;
|
||||||
collection->FindFamilyName(dwriteFamilyName, &familyNameIndex, &exists);
|
if (FAILED(m_TextFormat->GetFontCollection(collection.GetAddressOf())) ||
|
||||||
|
FAILED(collection->FindFamilyName(dwriteFamilyName, &familyNameIndex, &exists)) ||
|
||||||
Microsoft::WRL::ComPtr<IDWriteFontFamily> fontFamily;
|
FAILED(collection->GetFontFamily(familyNameIndex, fontFamily.GetAddressOf())))
|
||||||
collection->GetFontFamily(familyNameIndex, fontFamily.GetAddressOf());
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Microsoft::WRL::ComPtr<IDWriteFont> font;
|
Microsoft::WRL::ComPtr<IDWriteFont> font;
|
||||||
fontFamily->GetFirstMatchingFont(
|
hr = fontFamily->GetFirstMatchingFont(
|
||||||
m_TextFormat->GetFontWeight(),
|
m_TextFormat->GetFontWeight(),
|
||||||
m_TextFormat->GetFontStretch(),
|
m_TextFormat->GetFontStretch(),
|
||||||
m_TextFormat->GetFontStyle(),
|
m_TextFormat->GetFontStyle(),
|
||||||
font.GetAddressOf());
|
font.GetAddressOf());
|
||||||
|
if (FAILED(hr)) return;
|
||||||
|
|
||||||
DWRITE_FONT_METRICS fmetrics;
|
DWRITE_FONT_METRICS fmetrics;
|
||||||
font->GetMetrics(&fmetrics);
|
font->GetMetrics(&fmetrics);
|
||||||
|
Loading…
Reference in New Issue
Block a user