From 5e68a4e293455f3cc647aaf3c2bd3e380be77c20 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 11 Feb 2019 12:45:15 +0200 Subject: [PATCH] Fixed: Loss of precision when calculating text line width --HG-- branch : develop --- code/nel/include/nel/gui/view_text.h | 4 ++-- code/nel/src/gui/view_text.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index 195db5a62..fa5f74b84 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -442,9 +442,9 @@ namespace NLGUI // Clear all the lines and free their datas void clearLines(); // Update in the case of a multiline text - void updateTextContextMultiLine(uint nMaxWidth); + void updateTextContextMultiLine(float nMaxWidth); // Update in the case of a multiline text with justification - void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces); + void updateTextContextMultiLineJustified(float nMaxWidth, bool expandSpaces); // Recompute font size info void computeFontSize (); diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 47f128d96..45adbe245 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -1628,7 +1628,7 @@ namespace NLGUI // *************************************************************************** - void CViewText::updateTextContextMultiLine(uint nMaxWidth) + void CViewText::updateTextContextMultiLine(float nMaxWidth) { ucchar ucLetter; UTextContext::CStringInfo si; @@ -1741,7 +1741,7 @@ namespace NLGUI } // *************************************************************************** - void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces) + void CViewText::updateTextContextMultiLineJustified(float nMaxWidth, bool expandSpaces) { NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName); UTextContext::CStringInfo si; @@ -1847,10 +1847,10 @@ namespace NLGUI } // // Does the word go beyond the end of line ? - if (!lineFeed && newLineWidth > (float) nMaxWidth) + if (!lineFeed && newLineWidth > nMaxWidth) { // Have we enough room for this word on a line ? - bool roomForThisWord = (numWordsInLine > 0) || ( (newLineWidth - lineWidth) < (float) nMaxWidth ); + bool roomForThisWord = (numWordsInLine > 0) || ( (newLineWidth - lineWidth) < nMaxWidth ); // not enough room for that word // If it is the only word of the line, just split it @@ -1927,7 +1927,7 @@ namespace NLGUI word.build(wordValue, *TextContext, numSpaces); word.Format= wordFormat; _Lines.push_back(TLineSPtr(new CLine)); - float roomForSpaces = (float) nMaxWidth - word.Info.StringWidth; + float roomForSpaces = nMaxWidth - word.Info.StringWidth; if (expandSpaces && numSpaces != 0) { _Lines.back()->setSpaceWidth(roomForSpaces / (float) numSpaces);