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": { "lost": {
"color": g_TypeColors.red, "color": g_TypeColors.red,
"caption": translate("Lost"), "caption": translate("Lost"),
"postfix": "\n" "postfix": ""
}, },
"used": { "used": {
"color": g_TypeColors.red, "color": g_TypeColors.red,
"caption": translate("Used"), "caption": translate("Used"),
"postfix": "\n" "postfix": ""
}, },
"received": { "received": {
"color": g_TypeColors.red, "color": g_TypeColors.red,
"caption": translate("Received"), "caption": translate("Received"),
"postfix": "\n" "postfix": ""
}, },
"sold": { "sold": {
"color": g_TypeColors.red, "color": g_TypeColors.red,
"caption": translate("Sold"), "caption": translate("Sold"),
"postfix": "\n" "postfix": ""
}, },
"outcome": { "outcome": {
"color": g_TypeColors.red, "color": g_TypeColors.red,
"caption": translate("Outcome"), "caption": translate("Outcome"),
"postfix": "\n" "postfix": ""
}, },
"failed": { "failed": {
"color": g_TypeColors.red, "color": g_TypeColors.red,
"caption": translate("Failed"), "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. // Let line_height be the maximum m_Height we encounter.
line_height = std::max(line_height, Feedback2.m_Size.cy); 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) if (WordWrapping && Feedback2.m_NewLine)
break; break;
line_width += Feedback2.m_Size.cx;
} }
float dx = 0.f; float dx = 0.f;