{
const TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordIt );
+ const float shrunkWordWidth = wordLayoutInfo.mSize.width * shrinkFactor;
const bool isWhiteSpace = TextViewProcessor::WordSeparator == wordLayoutInfo.mType;
bool splitByCharacter = false;
}
case WrapByWordAndSplit:
{
- splitByCharacter = ( wordLayoutInfo.mSize.width * shrinkFactor > parentWidth );
+ splitByCharacter = ( shrunkWordWidth > parentWidth );
break;
}
case WrapByLineAndSplit:
{
if( ( 0 != characterIndex ) ||
- ( ( 0 == characterIndex ) && ( lineOffset + wordLayoutInfo.mSize.width * shrinkFactor > parentWidth ) ) )
+ ( ( 0 == characterIndex ) && ( lineOffset + shrunkWordWidth > parentWidth ) ) )
{
splitByCharacter = true;
}
else
{
- lineOffset += wordLayoutInfo.mSize.width * shrinkFactor;
+ lineOffset += shrunkWordWidth;
splitByCharacter = false;
}
}
}
else
{
- CalculateLineLength( isWhiteSpace, wordLayoutInfo.mSize.width * shrinkFactor, parentWidth, found, subLineInfo.mLineLength, endWhiteSpaceLength );
+ CalculateLineLength( isWhiteSpace, shrunkWordWidth, parentWidth, found, subLineInfo.mLineLength, endWhiteSpaceLength );
if( !found || isFirstCharacter )
{
subLineInfo.mMaxCharHeight = std::max( subLineInfo.mMaxCharHeight, wordLayoutInfo.mSize.height );
const float parentWidth = relayoutData.mTextViewSize.width;
TextViewProcessor::TextLayoutInfo& textLayoutInfo = relayoutData.mTextLayoutInfo;
+ relayoutData.mLineJustificationInfo.clear();
+
// Reset the text height. This value is returned in order to shrink further or not the text.
newTextHeight = 0.f;
( isFirstCharOfWord && ( wordOffset + wordLayoutInfo.mSize.width * shrinkFactor > parentWidth ) ) )
{
isFirstChar = false;
- const float minWidth = std::min( parentWidth, textLayoutInfo.mWholeTextSize.width );
// Calculates the line length and the max character height for the current line.
TextViewRelayout::SubLineLayoutInfo subLineInfo;
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
subLineInfo.mMaxAscender = 0.f;
- TextViewRelayout::CalculateSubLineLayout( minWidth,
+ TextViewRelayout::CalculateSubLineLayout( parentWidth,
indices,
lineLayoutInfo,
TextViewRelayout::WrapByWord,
shrinkFactor,
subLineInfo );
- float justificationOffset = TextViewRelayout::CalculateJustificationOffset( layoutParameters.mLineJustification, minWidth, subLineInfo.mLineLength );
-
- characterLayoutInfo.mPosition = Vector3( justificationOffset, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor, 0.f );
+ characterLayoutInfo.mPosition = Vector3( 0.f, previousPositionY + subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor, 0.f );
newTextHeight += subLineInfo.mMaxCharHeight + layoutParameters.mLineHeightOffset * shrinkFactor;
lineInfo.mSize = Size( subLineInfo.mLineLength, subLineInfo.mMaxCharHeight ); // Size of this piece of line.
lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
relayoutData.mLines.push_back( lineInfo );
+
+
+ // Stores some info to calculate the line justification in a post-process.
+ TextView::LineJustificationInfo justificationInfo;
+
+ justificationInfo.mIndices = indices;
+ justificationInfo.mLineLength = subLineInfo.mLineLength;
+
+ relayoutData.mLineJustificationInfo.push_back( justificationInfo );
}
else
{