From 30758c617dee3352070497133b24818674d5d646 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Thu, 20 Dec 2018 11:00:59 +0900 Subject: [PATCH] Fixed an incorrect ellipsis ex) An ellipsis may be displayed incorrectly when there are two or more new-line characters. check text in below samle "here to stay\n\n oh" TextLabee labe33 = TextLabel::New( "yesterday all my troubles seemed so far away\nnow it looks\n as though they`re here to stay\n\n ohi believe in yesterday" ); labe33.SetSize( 450, 145 ); labe33.SetParentOrigin(ParentOrigin::TOP_LEFT); labe33.SetAnchorPoint(AnchorPoint::TOP_LEFT); labe33.SetPosition( 100.f, 200.f); labe33.SetProperty(TextLabel::Property::POINT_SIZE, 17.6f); labe33.SetProperty( TextLabel::Property::MULTI_LINE, true ); labe33.SetProperty(TextLabel::Property::ELLIPSIS, true); stage.Add( labe33 ); When the index is decremented, it may be reduced to the index of the previous line. In this case, the value of firstPenX must be recalculated. Change-Id: I5cb73dac352d862894d78b86164b3a2c3b7a7c8c --- .../utc-Dali-Text-ViewModel.cpp | 34 +++++++++++++++++----- .../internal/text/rendering/view-model.cpp | 5 ++++ 2 files changed, 31 insertions(+), 8 deletions(-) mode change 100644 => 100755 automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp old mode 100644 new mode 100755 index 49d36e0..fc87193 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp @@ -71,6 +71,7 @@ struct ElideData unsigned int numberOfLines; unsigned int numberOfGlyphs; float* positions; + unsigned int ignoreOfGlyphs; }; bool ElideTest( const ElideData& data ) @@ -130,7 +131,7 @@ bool ElideTest( const ElideData& data ) if( numberOfLines != 0u ) { const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u ); - const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex; + const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex + data.ignoreOfGlyphs; std::cout << " last line alignment offset : " << lastLine.alignmentOffset << std::endl; @@ -594,6 +595,9 @@ int UtcDaliTextViewModelElideText02(void) Size textSize04( 80.f, 10.f ); float positions04[] = { 2.f }; + Size textSize05( 180.f, 100.f ); + float positions05[] = { 0.f, 0.f }; + struct ElideData data[] = { { @@ -602,7 +606,8 @@ int UtcDaliTextViewModelElideText02(void) textSize00, 0u, 0u, - NULL + NULL, + 0u }, { "Latin script", @@ -610,7 +615,8 @@ int UtcDaliTextViewModelElideText02(void) textSize01, 5u, 42u, - positions01 + positions01, + 0u }, { "Hebrew script", @@ -618,7 +624,8 @@ int UtcDaliTextViewModelElideText02(void) textSize02, 5u, 49u, - positions02 + positions02, + 0u }, { "Arabic script", @@ -626,7 +633,8 @@ int UtcDaliTextViewModelElideText02(void) textSize03, 5u, 79u, - positions03 + positions03, + 0u }, { "Small control size, no line fits.", @@ -634,10 +642,20 @@ int UtcDaliTextViewModelElideText02(void) textSize04, 1u, 1u, - positions04 - } + positions04, + 0u + }, + { + "Include newline character", + "yesterday\n all\n my troubles\n seemed so far\n\n away now it looks", + textSize05, + 5u, + 40, + positions05, + 5u + }, }; - const unsigned int numberOfTests = 5u; + const unsigned int numberOfTests = 6u; for( unsigned int index = 0u; index < numberOfTests; ++index ) { diff --git a/dali-toolkit/internal/text/rendering/view-model.cpp b/dali-toolkit/internal/text/rendering/view-model.cpp index 3543fce..27932b2 100755 --- a/dali-toolkit/internal/text/rendering/view-model.cpp +++ b/dali-toolkit/internal/text/rendering/view-model.cpp @@ -349,6 +349,11 @@ void ViewModel::ElideGlyphs() { if( index > 0u ) { + // If the index decreases to the previous line, firstPenX must be recalculated. + if( numberOfLaidOutGlyphs - index == lastLine.glyphRun.numberOfGlyphs) + { + firstPenSet = false; + } --index; } else -- 2.7.4