Gfx: Minor tweaks

This commit is contained in:
Birunthan Mohanathas
2013-08-12 18:50:48 +03:00
parent 12e0564f3e
commit db9e220207
2 changed files with 23 additions and 10 deletions

View File

@ -84,18 +84,21 @@ void TextFormatD2D::CreateLayout(
textLayout1->SetCharacterSpacing(emOffset, emOffset, 0.0f, range);
}
// If only one line is visible, disable wrapping so that as much text as possible is shown
// after trimming.
// TODO: Fix this for when more than one line is visible.
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)
if (SUCCEEDED(hr))
{
m_TextLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
// If only one line is visible, disable wrapping so that as much text as possible is shown
// after trimming.
// TODO: Fix this for when more than one line is visible.
if (lineCount >= 2 &&
lineMetrics[0].isTrimmed &&
lineMetrics[1].isTrimmed &&
lineMetrics[1].height == 0.0f)
{
m_TextLayout->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
}
}
}
}