+ if( characterDirection == paragraphDirection )
+ {
+ if( RTL == characterDirection )
+ {
+ // <--
+ // | Rrrrr|
+ // or
+ // | Rllrrr|
+ // or
+ // |lllrrrrr|
+ // | Rll|
+ //
+
+ tmpExtraBearing = ( 0.f > glyphInfo.xBearing ) ? -glyphInfo.xBearing : 0.f;
+ }
+ else // LTR
+ {
+ // -->
+ // |lllL |
+ // or
+ // |llrrL |
+ // or
+ // |lllllrrr|
+ // |rrL |
+ //
+
+ const float extraWidth = glyphInfo.xBearing + glyphInfo.width - glyphInfo.advance;
+ tmpExtraWidth = ( 0.f < extraWidth ) ? extraWidth : 0.f;
+ }
+ }
+ else
+ {
+ if( characterDirection != previousCharacterDirection )
+ {
+ if( RTL == characterDirection )
+ {
+ // -->
+ // |lllR |
+
+ const float extraWidth = glyphInfo.xBearing + glyphInfo.width - glyphInfo.advance;
+ tmpExtraWidth = ( 0.f < extraWidth ) ? extraWidth : 0.f;
+ }
+ else // LTR
+ {
+ // <--
+ // | Lrrrr|
+
+ tmpExtraBearing = ( 0.f > glyphInfo.xBearing ) ? -glyphInfo.xBearing : 0.f;
+ }
+ }
+ else if( characterDirection == firstCharacterDirection )
+ {
+ if( RTL == characterDirection )
+ {
+ // -->
+ // |llllllrr|
+ // |Rr |
+
+ tmpExtraBearing = ( 0.f > glyphInfo.xBearing ) ? -glyphInfo.xBearing : 0.f;
+ }
+ else // LTR
+ {
+ // <--
+ // |llllrrrr|
+ // | llL|
+
+ const float extraWidth = glyphInfo.xBearing + glyphInfo.width - glyphInfo.advance;
+ tmpExtraWidth = ( 0.f < extraWidth ) ? extraWidth : 0.f;
+ }
+ }
+ }
+
+ // Clear the white space length at the end of the line.
+ tmpLineLayout.wsLengthEndOfLine = 0.f;
+ }
+
+ // Check if the accumulated length fits in the width of the box.
+ if( ( completelyFill || isMultiline ) && !isWhiteSpace &&
+ ( tmpExtraBearing + lineLayout.length + lineLayout.wsLengthEndOfLine + tmpLineLayout.length + tmpExtraWidth > parameters.boundingBox.width ) )
+ {
+ // Current word does not fit in the box's width.
+ if( !oneWordLaidOut || completelyFill )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " Break the word by character\n" );
+
+ // The word's with doesn't fit in the control's with. It needs to be split by character.
+ if( tmpLineLayout.numberOfGlyphs > 0u )
+ {
+ tmpLineLayout.numberOfCharacters -= charactersPerGlyph;
+ --tmpLineLayout.numberOfGlyphs;
+ tmpLineLayout.length = previousTmpLineLength;
+ tmpExtraBearing = previousTmpExtraBearing;
+ tmpExtraWidth = previousTmpExtraWidth;
+ }
+
+ // Add part of the word to the line layout.
+ MergeLineLayout( lineLayout, tmpLineLayout );
+ }
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " Current word does not fit.\n" );
+ }
+
+ lineLayout.extraBearing = tmpExtraBearing;
+ lineLayout.extraWidth = tmpExtraWidth;
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--GetLineLayoutForBox.\n" );
+
+ return;
+ }
+
+ if( ( isMultiline || isLastGlyph ) &&
+ ( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo ) )
+ {
+ // Must break the line. Update the line layout and return.
+ MergeLineLayout( lineLayout, tmpLineLayout );
+
+ // Set the next paragraph's direction.
+ if( !isLastGlyph &&
+ ( NULL != parameters.characterDirectionBuffer ) )
+ {
+ paragraphDirection = *( parameters.characterDirectionBuffer + 1u + characterLastIndex );
+ }
+
+ lineLayout.extraBearing = tmpExtraBearing;
+ lineLayout.extraWidth = tmpExtraWidth;
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " Must break\n" );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--GetLineLayoutForBox\n" );
+ return;
+ }
+
+ if( isMultiline &&
+ ( TextAbstraction::WORD_BREAK == wordBreakInfo ) )
+ {
+ oneWordLaidOut = true;
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, " One word laid out\n" );
+
+ // Current glyph is the last one of the current word.
+ // Add the temporal layout to the current one.
+ MergeLineLayout( lineLayout, tmpLineLayout );
+
+ tmpLineLayout.Clear();
+ }
+
+ previousCharacterDirection = characterDirection;