Fixed: Loss of precision when calculating text line width

--HG--
branch : develop
feature/pipeline-tools
Nimetu 6 years ago
parent 07d9107b6b
commit 5e68a4e293

@ -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 ();

@ -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);

Loading…
Cancel
Save