Fixed: Loss of precision when calculating text line width
--HG-- branch : develop
This commit is contained in:
parent
07d9107b6b
commit
5e68a4e293
2 changed files with 7 additions and 7 deletions
|
@ -442,9 +442,9 @@ namespace NLGUI
|
||||||
// Clear all the lines and free their datas
|
// Clear all the lines and free their datas
|
||||||
void clearLines();
|
void clearLines();
|
||||||
// Update in the case of a multiline text
|
// 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
|
// 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
|
// Recompute font size info
|
||||||
void computeFontSize ();
|
void computeFontSize ();
|
||||||
|
|
||||||
|
|
|
@ -1628,7 +1628,7 @@ namespace NLGUI
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::updateTextContextMultiLine(uint nMaxWidth)
|
void CViewText::updateTextContextMultiLine(float nMaxWidth)
|
||||||
{
|
{
|
||||||
ucchar ucLetter;
|
ucchar ucLetter;
|
||||||
UTextContext::CStringInfo si;
|
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);
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
UTextContext::CStringInfo si;
|
UTextContext::CStringInfo si;
|
||||||
|
@ -1847,10 +1847,10 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Does the word go beyond the end of line ?
|
// 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 ?
|
// 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
|
// not enough room for that word
|
||||||
// If it is the only word of the line, just split it
|
// If it is the only word of the line, just split it
|
||||||
|
@ -1927,7 +1927,7 @@ namespace NLGUI
|
||||||
word.build(wordValue, *TextContext, numSpaces);
|
word.build(wordValue, *TextContext, numSpaces);
|
||||||
word.Format= wordFormat;
|
word.Format= wordFormat;
|
||||||
_Lines.push_back(TLineSPtr(new CLine));
|
_Lines.push_back(TLineSPtr(new CLine));
|
||||||
float roomForSpaces = (float) nMaxWidth - word.Info.StringWidth;
|
float roomForSpaces = nMaxWidth - word.Info.StringWidth;
|
||||||
if (expandSpaces && numSpaces != 0)
|
if (expandSpaces && numSpaces != 0)
|
||||||
{
|
{
|
||||||
_Lines.back()->setSpaceWidth(roomForSpaces / (float) numSpaces);
|
_Lines.back()->setSpaceWidth(roomForSpaces / (float) numSpaces);
|
||||||
|
|
Loading…
Reference in a new issue