From a49a044e847e3b6d3734519c41098e200cd12d5d Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Mon, 29 Jan 2018 16:22:18 +0900 Subject: [PATCH 1/1] 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 --- dali-toolkit/internal/text/layouts/layout-engine.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; }; -- 2.7.4