Stop new-line characters making lines longer than they should be.

Reviewed By: Imarok
Fixes: #3351
Differential Revision: https://code.wildfiregames.com/D1299
This was SVN commit r21546.
This commit is contained in:
s0600204 2018-03-13 23:06:21 +00:00
parent 0f86ff6e48
commit afd69a58b3
2 changed files with 12 additions and 8 deletions

View File

@ -78,32 +78,32 @@ var g_SummaryTypes = {
"lost": {
"color": g_TypeColors.red,
"caption": translate("Lost"),
"postfix": "\n"
"postfix": ""
},
"used": {
"color": g_TypeColors.red,
"caption": translate("Used"),
"postfix": "\n"
"postfix": ""
},
"received": {
"color": g_TypeColors.red,
"caption": translate("Received"),
"postfix": "\n"
"postfix": ""
},
"sold": {
"color": g_TypeColors.red,
"caption": translate("Sold"),
"postfix": "\n"
"postfix": ""
},
"outcome": {
"color": g_TypeColors.red,
"caption": translate("Outcome"),
"postfix": "\n"
"postfix": ""
},
"failed": {
"color": g_TypeColors.red,
"caption": translate("Failed"),
"postfix": "\n"
"postfix": ""
}
};

View File

@ -690,10 +690,14 @@ SGUIText CGUI::GenerateText(const CGUIString& string, const CStrW& FontW, const
// Let line_height be the maximum m_Height we encounter.
line_height = std::max(line_height, Feedback2.m_Size.cy);
line_width += Feedback2.m_Size.cx;
// If the current word is an explicit new line ("\n"),
// break now before adding the width of this character.
// ("\n" doesn't have a glyph, thus is given the same width as
// the "missing glyph" character by CFont::GetCharacterWidth().)
if (WordWrapping && Feedback2.m_NewLine)
break;
line_width += Feedback2.m_Size.cx;
}
float dx = 0.f;