X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Flayouts%2Flayout-engine.cpp;h=061707a7bffd434c422e2877b4a8a0b262d78b7f;hp=dd429a15518fdc0d0fafb19a3d6e8fe0815641f1;hb=9346cf33ef49063185d54fbbfc186864d96c51ca;hpb=b5b774f066e74e54a2e6f4bf923d1501f21f1284 diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index dd429a1..061707a 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -109,7 +109,8 @@ struct Engine::Impl Impl() : mLayout( Layout::Engine::SINGLE_LINE_BOX ), mCursorWidth( CURSOR_WIDTH ), - mDefaultLineSpacing( LINE_SPACING ) + mDefaultLineSpacing( LINE_SPACING ), + mPreviousCharacterExtraWidth( 0.0f ) { } @@ -280,9 +281,6 @@ struct Engine::Impl // Get the line break info for the current character. const LineBreakInfo lineBreakInfo = hasCharacters ? *( parameters.lineBreakInfoBuffer + characterLastIndex ) : TextAbstraction::LINE_NO_BREAK; - // Get the word break info for the current character. - const WordBreakInfo wordBreakInfo = *( parameters.wordBreakInfoBuffer + characterLastIndex ); - // Increase the number of characters. tmpLineLayout.numberOfCharacters += charactersPerGlyph; @@ -345,6 +343,7 @@ struct Engine::Impl const float extraWidth = glyphMetrics.xBearing + glyphMetrics.width - glyphMetrics.advance; tmpExtraWidth = ( 0.f < extraWidth ) ? extraWidth : 0.f; + tmpExtraWidth = std::max( mPreviousCharacterExtraWidth - glyphMetrics.advance, tmpExtraWidth ); } } else @@ -358,6 +357,7 @@ struct Engine::Impl const float extraWidth = glyphMetrics.xBearing + glyphMetrics.width - glyphMetrics.advance; tmpExtraWidth = ( 0.f < extraWidth ) ? extraWidth : 0.f; + tmpExtraWidth = std::max( mPreviousCharacterExtraWidth - glyphMetrics.advance, tmpExtraWidth ); } else // LTR { @@ -385,6 +385,7 @@ struct Engine::Impl const float extraWidth = glyphMetrics.xBearing + glyphMetrics.width - glyphMetrics.advance; tmpExtraWidth = ( 0.f < extraWidth ) ? extraWidth : 0.f; + tmpExtraWidth = std::max( mPreviousCharacterExtraWidth - glyphMetrics.advance, tmpExtraWidth ); } } } @@ -393,8 +394,19 @@ struct Engine::Impl tmpLineLayout.wsLengthEndOfLine = 0.f; } + // If calculation is end but wsLengthEndOfLine is exist, it means end of text is space. + // Merge remained length. + if ( !parameters.ignoreSpaceAfterText && glyphIndex == lastGlyphOfParagraphPlusOne-1 && tmpLineLayout.wsLengthEndOfLine > 0 ) + { + tmpLineLayout.length += tmpLineLayout.wsLengthEndOfLine; + tmpLineLayout.wsLengthEndOfLine = 0u; + } + + // Save the current extra width to compare with the next one + mPreviousCharacterExtraWidth = tmpExtraWidth; + // Check if the accumulated length fits in the width of the box. - if( ( completelyFill || isMultiline ) && !isWhiteSpace && + if( ( completelyFill || isMultiline ) && !(parameters.ignoreSpaceAfterText && isWhiteSpace) && ( tmpExtraBearing + lineLayout.length + lineLayout.wsLengthEndOfLine + tmpLineLayout.length + tmpExtraWidth > parameters.boundingBox.width ) ) { // Current word does not fit in the box's width. @@ -451,7 +463,7 @@ struct Engine::Impl } if( isMultiline && - ( TextAbstraction::WORD_BREAK == wordBreakInfo ) ) + ( TextAbstraction::LINE_ALLOW_BREAK == lineBreakInfo ) ) { oneWordLaidOut = isWordLaidOut; DALI_LOG_INFO( gLogFilter, Debug::Verbose, " One word laid-out\n" ); @@ -1217,6 +1229,7 @@ struct Engine::Impl Type mLayout; float mCursorWidth; float mDefaultLineSpacing; + float mPreviousCharacterExtraWidth; IntrusivePtr mMetrics; };