mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Handle failed creation of D2D text layout
This commit is contained in:
parent
6d243711a6
commit
ca41a4575c
@ -318,11 +318,11 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
||||
|
||||
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> solidBrush;
|
||||
HRESULT hr = m_Target->CreateSolidColorBrush(ToColorF(color), solidBrush.GetAddressOf());
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
if (FAILED(hr)) return;
|
||||
|
||||
TextFormatD2D& formatD2D = (TextFormatD2D&)format;
|
||||
formatD2D.CreateLayout(
|
||||
str, strLen, rect.Width, rect.Height, !m_AccurateText && m_TextAntiAliasing);
|
||||
if (!formatD2D.CreateLayout(
|
||||
str, strLen, rect.Width, rect.Height, !m_AccurateText && m_TextAntiAliasing)) return;
|
||||
|
||||
D2D1_POINT_2F drawPosition;
|
||||
drawPosition.x = [&]()
|
||||
@ -382,7 +382,6 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
||||
m_Target->PopLayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CanvasD2D::MeasureTextW(const WCHAR* str, UINT strLen, const TextFormat& format, Gdiplus::RectF& rect)
|
||||
|
@ -43,7 +43,7 @@ void TextFormatD2D::Dispose()
|
||||
m_LineGap = 0.0f;
|
||||
}
|
||||
|
||||
void TextFormatD2D::CreateLayout(
|
||||
bool TextFormatD2D::CreateLayout(
|
||||
const WCHAR* str, UINT strLen, float maxW, float maxH, bool gdiEmulation)
|
||||
{
|
||||
bool strChanged = false;
|
||||
@ -84,9 +84,8 @@ void TextFormatD2D::CreateLayout(
|
||||
{
|
||||
CanvasD2D::c_DWFactory->CreateTextLayout(
|
||||
str, strLen, m_TextFormat.Get(), maxW, maxH, m_TextLayout.ReleaseAndGetAddressOf());
|
||||
if (!m_TextLayout) return false;
|
||||
|
||||
if (m_TextLayout)
|
||||
{
|
||||
if (gdiEmulation)
|
||||
{
|
||||
Microsoft::WRL::ComPtr<IDWriteTextLayout1> textLayout1;
|
||||
@ -115,7 +114,8 @@ void TextFormatD2D::CreateLayout(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextFormatD2D::SetProperties(
|
||||
|
@ -55,8 +55,8 @@ private:
|
||||
|
||||
// Creates a new DirectWrite text layout if |str| has changed since last call. Since creating
|
||||
// the layout is costly, it is more efficient to keep reusing the text layout until the text
|
||||
// changes.
|
||||
void CreateLayout(const WCHAR* str, UINT strLen, float maxW, float maxH, bool gdiEmulation);
|
||||
// changes. Returns true if the layout is valid for use.
|
||||
bool CreateLayout(const WCHAR* str, UINT strLen, float maxW, float maxH, bool gdiEmulation);
|
||||
|
||||
DWRITE_TEXT_METRICS GetMetrics(
|
||||
const WCHAR* str, UINT strLen, bool gdiEmulation, float maxWidth = 10000.0f);
|
||||
|
Loading…
Reference in New Issue
Block a user