mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Improve line trimming with D2D when one line is visible
This commit is contained in:
parent
34abccc29b
commit
56218f7af4
@ -70,7 +70,9 @@ void TextFormatD2D::CreateLayout(
|
||||
CanvasD2D::c_DWFactory->CreateTextLayout(
|
||||
str, strLen, m_TextFormat.Get(), maxW, maxH, m_TextLayout.ReleaseAndGetAddressOf());
|
||||
|
||||
if (gdiEmulation && m_TextLayout)
|
||||
if (m_TextLayout)
|
||||
{
|
||||
if (gdiEmulation)
|
||||
{
|
||||
Microsoft::WRL::ComPtr<IDWriteTextLayout1> textLayout1;
|
||||
m_TextLayout.As(&textLayout1);
|
||||
@ -80,6 +82,19 @@ void TextFormatD2D::CreateLayout(
|
||||
const DWRITE_TEXT_RANGE range = {0, strLen};
|
||||
textLayout1->SetCharacterSpacing(emOffset, emOffset, 0.0f, range);
|
||||
}
|
||||
|
||||
UINT32 lineCount = 0;
|
||||
DWRITE_LINE_METRICS lineMetrics[2];
|
||||
HRESULT hr = m_TextLayout->GetLineMetrics(lineMetrics, _countof(lineMetrics), &lineCount);
|
||||
if (SUCCEEDED(hr) &&
|
||||
lineMetrics[0].isTrimmed &&
|
||||
lineMetrics[1].isTrimmed &&
|
||||
lineMetrics[1].height == 0.0f)
|
||||
{
|
||||
m_TextLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user