From: Seoyeon Kim Date: Mon, 29 Jan 2018 07:22:18 +0000 (+0900) Subject: Save the previous character's extra width X-Git-Tag: dali_1.3.10~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=a49a044e847e3b6d3734519c41098e200cd12d5d;hp=-c Save the previous character's extra width - Added mPreviousCharacterExtraWidth in LayoutEngine to compare the current character's extra width with the next character's. Change-Id: Ic8cb093328f082dbb972441631fea9320ff9f6f8 Signed-off-by: Seoyeon Kim --- a49a044e847e3b6d3734519c41098e200cd12d5d diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index dd429a1..af257ff 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 ) { } @@ -345,6 +346,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 +360,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 +388,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,6 +397,9 @@ struct Engine::Impl tmpLineLayout.wsLengthEndOfLine = 0.f; } + // 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 && ( tmpExtraBearing + lineLayout.length + lineLayout.wsLengthEndOfLine + tmpLineLayout.length + tmpExtraWidth > parameters.boundingBox.width ) ) @@ -1217,6 +1224,7 @@ struct Engine::Impl Type mLayout; float mCursorWidth; float mDefaultLineSpacing; + float mPreviousCharacterExtraWidth; IntrusivePtr mMetrics; };