From ca8b48b0711b574b7ad36a7630b352001dee37d2 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Thu, 2 May 2019 16:35:30 +0900 Subject: [PATCH] Fixed an incorrect ellipsis MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ex) 1. An ellipsis may be displayed incorrectly when there are two or more new-line characters. 2. The ellipsis location is incorrectly displayed for RTL text. TextLabel textLabel1 = TextLabel::New( "abcdef הגדרות מהירות "); textLabel1.SetSize( 150.f, 100.f ); textLabel1.SetProperty( TextLabel::Property::POINT_SIZE, 20.f ); textLabel1.SetProperty( TextLabel::Property::ELLIPSIS, true ); textLabel1.SetPosition( 100.f, 50.f ); textLabel1.SetParentOrigin( ParentOrigin::TOP_LEFT ); textLabel1.SetAnchorPoint( AnchorPoint::TOP_LEFT ); stage.Add( textLabel1 ); TextLabel textLabel2 = TextLabel::New( "הגדרות מהירות"); textLabel2.SetSize( 150.f, 100.f ); textLabel2.SetProperty( TextLabel::Property::POINT_SIZE, 20.f ); textLabel2.SetProperty( TextLabel::Property::ELLIPSIS, true ); textLabel2.SetPosition( 100.f, 125.f ); textLabel2.SetParentOrigin( ParentOrigin::TOP_LEFT ); textLabel2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); stage.Add( textLabel2 ); TextLabel labe21 = TextLabel::New( "yesterday all my troubles seemed so far away now it looks as though they`re here to stay oh i believe in yesterday" ); labe21.SetSize( 450, 145 ); labe21.SetParentOrigin(ParentOrigin::TOP_LEFT); labe21.SetAnchorPoint(AnchorPoint::TOP_LEFT); labe21.SetPosition( 100.f, 200.f); labe21.SetProperty(TextLabel::Property::POINT_SIZE, 17.6f); labe21.SetProperty(TextLabel::Property::ELLIPSIS, true); stage.Add( labe21 ); TextLabel 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, 250.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 ); TextLabel labe34 = TextLabel::New( "yesterday all my troubles seemed so\n\n\n\n far away now it looks" ); labe34.SetSize( 450, 100 ); labe34.SetParentOrigin(ParentOrigin::TOP_LEFT); labe34.SetAnchorPoint(AnchorPoint::TOP_LEFT); labe34.SetPosition( 100.f, 400.f); labe34.SetProperty(TextLabel::Property::POINT_SIZE, 17.6f); labe34.SetProperty( TextLabel::Property::MULTI_LINE, true ); labe34.SetProperty(TextLabel::Property::ELLIPSIS, true); stage.Add( labe34 ); Change-Id: Ie856e38035b5ea6d179ec23ec04a1a9371486b73 --- .../src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp | 4 ++-- dali-toolkit/internal/text/rendering/view-model.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) 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 index a7df603..ba72d93 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp @@ -586,10 +586,10 @@ int UtcDaliTextViewModelElideText02(void) float positions01[] = { 0.f, 8.f, 16.f, 26.f, 33.f, 41.f, 45.f, 54.f, 64.0f }; Size textSize02( 80.f, 100.f ); - float positions02[] = { 75.f, 66.f, 57.f, 53.f, 46.f, 41.f, 33.f, 26.0f }; + float positions02[] = { 75.f, 66.f, 57.f, 53.f, 46.f, 41.f, 33.f, 12.0f }; Size textSize03( 80.f, 100.f ); - float positions03[] = { 79.f, 74.f, 71.f, 66.f, 58.f, 56.f, 52.f, 51.f, 46.f, 36.f, 33.f, 25.f, 22.f }; + float positions03[] = { 79.f, 74.f, 71.f, 66.f, 58.f, 56.f, 52.f, 51.f, 46.f, 36.f, 33.f, 25.f, 8.f }; Size textSize04( 80.f, 10.f ); float positions04[] = { 2.f }; diff --git a/dali-toolkit/internal/text/rendering/view-model.cpp b/dali-toolkit/internal/text/rendering/view-model.cpp index 0a977f3..83a518b 100755 --- a/dali-toolkit/internal/text/rendering/view-model.cpp +++ b/dali-toolkit/internal/text/rendering/view-model.cpp @@ -297,7 +297,7 @@ void ViewModel::ElideGlyphs() // Need to reshape the glyph as the font may be different in size. const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) ); - if( !firstPenSet ) + if( !firstPenSet || glyphToRemove.advance == 0.f ) { const Vector2& position = *( elidedPositionsBuffer + index ); @@ -332,6 +332,11 @@ void ViewModel::ElideGlyphs() glyphInfo = ellipsisGlyph; // Change the 'x' and 'y' position of the ellipsis glyph. + if( position.x > firstPenX ) + { + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + position.x += ellipsisGlyph.xBearing; position.y = penY - ellipsisGlyph.yBearing; -- 2.7.4