From 528ee21711fc507b20ddb031cf6b1d71f1f44e75 Mon Sep 17 00:00:00 2001 From: ssabah Date: Sun, 5 Jun 2022 15:08:04 +0300 Subject: [PATCH] Resolve incorrect position for Ellipsis when mixed LTR & RTL languages and set layout direction RTL MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Here's sample code for issues: //Case 1: TextLabel textLabel = TextLabel::New("Projector استكشاف"); textLabel.SetProperty(Dali::Toolkit::DevelTextLabel::Property::ELLIPSIS, true); textLabel.SetProperty(Dali::Toolkit::DevelTextLabel::Property::ELLIPSIS_POSITION, Dali::Toolkit::DevelText::EllipsisPosition::END); textLabel.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT); textLabel.SetProperty(Actor::Property::SIZE, Vector2(145.0f, 60.0f)); // minimize width until the ellipsis comes between two languages //Case 2: TextLabel textLabel = TextLabel::New("استكشاف Projector"); textLabel.SetProperty(Dali::Toolkit::DevelTextLabel::Property::ELLIPSIS, true); textLabel.SetProperty(Dali::Toolkit::DevelTextLabel::Property::ELLIPSIS_POSITION, Dali::Toolkit::DevelText::EllipsisPosition::START); textLabel.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT); textLabel.SetProperty(Actor::Property::SIZE, Vector2(145.0f, 60.0f)); // minimize width until the ellipsis comes between two languages Change-Id: Ia645d143083074383f4db3b8b2407810b69e4862 --- .../utc-Dali-Text-Ellipsis.cpp | 1464 ++++++++++---------- .../internal/text/rendering/view-model.cpp | 66 +- dali-toolkit/internal/text/text-view.cpp | 67 +- 3 files changed, 840 insertions(+), 757 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp index bab8800..75d8bb4 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp @@ -74,7 +74,7 @@ namespace ControllerPtr controller = Controller::New(); // Tests the rendering controller has been created. - TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() ); + TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel()); DALI_TEST_CHECK(typesetter); // Tests the view model has been created. @@ -91,7 +91,7 @@ namespace controller->SetLineWrapMode( (Text::LineWrap::Mode)(data.lineWrapMode) ); controller->SetEllipsisPosition( data.ellipsisPosition ); - controller->SetText( data.text ); + controller->SetText(data.text); controller->Relayout( data.size ); // Elide the glyphs. @@ -532,780 +532,736 @@ int UtcDaliTextLabelElideTextLocation(void) Size textSize36( 120.0f, 30.0f ); float positions36[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f }; + Size textSize37(145.0f, 30.0f); + float positions37[] = {131.0f, 126.0f, 121.0f, 116.0f, 108.0f, 103.0f, 93.0f, 88.0f, 20.0f, 29.0f, 34.0f, 42.0f, 48.0f, 57.0f, 67.0f}; + + Size textSize38(145.0f, 30.0f); + float positions38[] = {51.0f, 66.0f, 71.0f, 79.0f, 85.0f, 94.0f, 103.0f, 109.0f, 119.0f, 51.0f, 37.0f, 32.0f, 27.0f, 23.0f, 14.0f, 10.0f, 0.0f}; + struct ElideData data[] = - { { - "void text", - "", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize00, - 0u, - 0u, - nullptr - }, + {"void text", + "", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize00, + 0u, + 0u, + nullptr}, + + {"void text", + "", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize00, + 0u, + 0u, + nullptr}, + + {"void text", + "", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize00, + 0u, + 0u, + nullptr}, + + //END LTR cases + { + "EllipsisPosition: TextLabel: Basic case SingleLine LTR END", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize01, + 1u, + 10u, + positions01}, + + {"EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR END", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize02, + 2u, + 22u, + positions02}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR END", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize03, + 3u, + 29u, + positions03}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR END", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::CHARACTER, + DevelText::EllipsisPosition::END, + false, + textSize04, + 3u, + 40u, + positions04}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR END", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::HYPHENATION, + DevelText::EllipsisPosition::END, + false, + textSize05, + 3u, + 32u, + positions05}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR END", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::MIXED, + DevelText::EllipsisPosition::END, + false, + textSize06, + 3u, + 28u, + positions06}, + + //START LTR cases + { + "EllipsisPosition: TextLabel: Basic case SingleLine LTR START", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize07, + 1u, + 11u, + positions07, + + }, + + {"EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR START", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize08, + 2u, + 23u, + positions08}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR START", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize09, + 3u, + 33u, + positions09}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR START", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::CHARACTER, + DevelText::EllipsisPosition::START, + false, + textSize10, + 3u, + 37u, + positions10}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR START", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::HYPHENATION, + DevelText::EllipsisPosition::START, + false, + textSize11, + 3u, + 25u, + positions11}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR START", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::MIXED, + DevelText::EllipsisPosition::START, + false, + textSize12, + 3u, + 25u, + positions12}, + + //END RTL cases + { + "EllipsisPosition: TextLabel: SingleLine RTL END", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize13, + 1u, + 14u, + positions13}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL END", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize14, + 3u, + 42u, + positions14}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL END", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::CHARACTER, + DevelText::EllipsisPosition::END, + false, + textSize15, + 3u, + 44u, + positions15}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL END", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::HYPHENATION, + DevelText::EllipsisPosition::END, + false, + textSize16, + 3u, + 39u, + positions16}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL END", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::MIXED, + DevelText::EllipsisPosition::END, + false, + textSize17, + 3u, + 39u, + positions17}, + + //START RTL cases + { + "EllipsisPosition: TextLabel: SingleLine RTL START", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize18, + 1u, + 13u, + positions18}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL START", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize19, + 3u, + 33u, + positions19}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL START", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::CHARACTER, + DevelText::EllipsisPosition::START, + false, + textSize20, + 3u, + 30u, + positions20}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL START", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::HYPHENATION, + DevelText::EllipsisPosition::START, + false, + textSize21, + 3u, + 33u, + positions21}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL START", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::MIXED, + DevelText::EllipsisPosition::START, + false, + textSize22, + 3u, + 33u, + positions22}, + + //MIDDLE LTR cases + { + "EllipsisPosition: TextLabel: Basic case SingleLine LTR MIDDLE", + "ABCDEFGHIJKLMNPQRSTUVWXYZ abcdefghijklmnpqrstuvwxyz", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize23, + 1u, + 10u, + positions23}, + + {"EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR MIDDLE", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize24, + 2u, + 22u, + positions24}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR MIDDLE", + "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize25, + 3u, + 24u, + positions25}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR MIDDLE", + "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye", + true, + DevelText::LineWrap::CHARACTER, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize26, + 3u, + 36u, + positions26}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR MIDDLE", + "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye", + true, + DevelText::LineWrap::HYPHENATION, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize27, + 3u, + 27u, + positions27}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR MIDDLE", + "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye", + true, + DevelText::LineWrap::MIXED, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize28, + 3u, + 24u, + positions28}, + + //MIDDLE RTL cases + { + "EllipsisPosition: TextLabel: SingleLine RTL MIDDLE", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize29, + 1u, + 13u, + positions29}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL MIDDLE", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize30, + 3u, + 31u, + positions30}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL MIDDLE", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::CHARACTER, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize31, + 3u, + 29u, + positions31}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL MIDDLE", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::HYPHENATION, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize32, + 3u, + 31u, + positions32}, + + {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL MIDDLE", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + true, + DevelText::LineWrap::MIXED, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize33, + 3u, + 31u, + positions33}, + + {"EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR END", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize34, + 1u, + 13u, + positions34}, + + {"EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR START", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize35, + 1u, + 11u, + positions35}, + + {"EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR MIDDLE", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + true, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize36, + 1u, + 12u, + positions36}, + + {"EllipsisPosition: TextLabel: Mixed Directions Languages END", + "سیٹنگیں Projector سیٹنگیں", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize37, + 1u, + 16u, + positions37}, + + {"EllipsisPosition: TextLabel: Mixed Directions Languages START", + "سیٹنگیں Projector سیٹنگیں", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize38, + 1u, + 17u, + positions38}, + + }; + const unsigned int numberOfTests = 41u; + for( unsigned int index = 0u; index < numberOfTests; ++index ) + { + ToolkitTestApplication application; + if( !ElideTestViewModel( data[index] ) ) { - "void text", - "", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize00, - 0u, - 0u, - nullptr - }, + tet_result(TET_FAIL); + } + } - { - "void text", - "", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize00, - 0u, - 0u, - nullptr - }, + tet_result(TET_PASS); + END_TEST; +} - //END LTR cases - { - "EllipsisPosition: TextLabel: Basic case SingleLine LTR END", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize01, - 1u, - 10u, - positions01 - }, - { - "EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR END", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize02, - 2u, - 22u, - positions02 - }, +int UtcDaliTextFieldlElideTextLocation(void) +{ + tet_infoline(" UtcDaliTextFieldlElideTextLocation "); - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR END", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize03, - 3u, - 29u, - positions03 - }, + Size textSize00( 100.f, 100.f ); - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR END", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::CHARACTER, - DevelText::EllipsisPosition::END, - false, - textSize04, - 3u, - 40u, - positions04 - }, + Size textSize01( 120.0f, 50.0f ); + float positions01[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 50.0f, 60.0f, 70.0f, 80.0f, 91.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR END", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::HYPHENATION, - DevelText::EllipsisPosition::END, - false, - textSize05, - 3u, - 32u, - positions05 - }, + Size textSize02( 120.0f, 50.0f ); + float positions02[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f, 59.0f, 65.0f, 73.0f, 84.0f, 93.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR END", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::MIXED, - DevelText::EllipsisPosition::END, - false, - textSize06, - 3u, - 28u, - positions06 - }, + Size textSize03( 120.0f, 50.0f ); + float positions03[] = { 117.0f, 111.0f, 97.0f, 88.0f, 80.0f, 74.0f, 64.0f, 59.0f, 54.0f, 45.0f, 37.0f, 31.0f, 22.0f, 7.0f }; - //START LTR cases - { - "EllipsisPosition: TextLabel: Basic case SingleLine LTR START", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize07, - 1u, - 11u, - positions07 - }, + Size textSize04( 120.0f, 50.0f ); + float positions04[] = { 5.0f, 21.0f, 31.0f, 41.0f, 50.0f, 61.0f, 71.0f, 80.0f, 90.0f, 100.0f, 109.0f }; - { - "EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR START", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize08, - 2u, - 23u, - positions08 - }, + Size textSize05( 120.0f, 50.0f ); + float positions05[] = { 8.0f, 24.0f, 35.0f, 44.0f, 49.0f, 63.0f, 74.0f, 77.0f, 85.0f, 96.0f, 110.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR START", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize09, - 3u, - 33u, - positions09 - }, + Size textSize06( 120.0f, 50.0f ); + float positions06[] = { 90.0f, 79.0f, 70.0f, 68.0f, 62.0f, 56.0f, 51.0f, 42.0f, 29.0f, 26.0f, 15.0f, 7.0f, 0.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR START", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::CHARACTER, - DevelText::EllipsisPosition::START, - false, - textSize10, - 3u, - 37u, - positions10 - }, + Size textSize07( 120.0f, 50.0f ); + float positions07[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 53.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR START", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::HYPHENATION, - DevelText::EllipsisPosition::START, - false, - textSize11, - 3u, - 25u, - positions11 - }, + Size textSize08( 120.0f, 50.0f ); + float positions08[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR START", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::MIXED, - DevelText::EllipsisPosition::START, - false, - textSize12, - 3u, - 25u, - positions12 - }, + Size textSize09( 120.0f, 50.0f ); + float positions09[] = { 116.0f, 109.0f, 96.0f, 87.0f, 79.0f, 73.0f, 63.0f }; - //END RTL cases - { - "EllipsisPosition: TextLabel: SingleLine RTL END", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize13, - 1u, - 14u, - positions13 - }, + Size textSize10( 120.0f, 50.0f ); + float positions10[] = { 121.0f, 116.0f, 111.0f, 106.0f, 101.0f, 96.0f, 92.0f, 87.0f, 83.0f, 77.0f, 63.0f, 55.0f, 46.0f, 40.0f, 30.0f, 16.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL END", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize14, - 3u, - 42u, - positions14 - }, + Size textSize11( 120.0f, 50.0f ); + float positions11[] = { 93.0f, 77.0f, 74.0f, 63.0f, 56.0f, 49.0f, 44.0f, 39.0f, 34.0f, 29.0f, 24.0f, 19.0f, 14.0f, 9.0f, 5.0f }; - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL END", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::CHARACTER, - DevelText::EllipsisPosition::END, - false, - textSize15, - 3u, - 44u, - positions15 - }, + Size textSize12( 120.0f, 50.0f ); + float positions12[] = { 117.0f, 112.0f, 107.0f, 102.0f, 97.0f, 92.0f, 87.0f, 82.0f, 79.0f, 72.0f }; + Size textSize13(145.0f, 30.0f); + float positions13[] = {131.0f, 126.0f, 121.0f, 117.0f, 108.0f, 104.0f, 94.0f, 88.0f, 20.0f, 29.0f, 34.0f, 42.0f, 48.0f, 57.0f, 67.0f}; + + Size textSize14(145.0f, 30.0f); + float positions14[] = {51.0f, 66.0f, 71.0f, 80.0f, 85.0f, 94.0f, 103.0f, 109.0f, 119.0f, 51.0f, 37.0f, 32.0f, 28.0f, 23.0f, 14.0f, 10.0f, 0.0f}; + + struct ElideData data[] = { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL END", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::HYPHENATION, - DevelText::EllipsisPosition::END, - false, - textSize16, - 3u, - 39u, - positions16 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL END", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::MIXED, - DevelText::EllipsisPosition::END, - false, - textSize17, - 3u, - 39u, - positions17 - }, - - //START RTL cases - { - "EllipsisPosition: TextLabel: SingleLine RTL START", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize18, - 1u, - 13u, - positions18 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL START", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize19, - 3u, - 33u, - positions19 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL START", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::CHARACTER, - DevelText::EllipsisPosition::START, - false, - textSize20, - 3u, - 30u, - positions20 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL START", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::HYPHENATION, - DevelText::EllipsisPosition::START, - false, - textSize21, - 3u, - 33u, - positions21 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL START", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::MIXED, - DevelText::EllipsisPosition::START, - false, - textSize22, - 3u, - 33u, - positions22 - }, - - //MIDDLE LTR cases - { - "EllipsisPosition: TextLabel: Basic case SingleLine LTR MIDDLE", - "ABCDEFGHIJKLMNPQRSTUVWXYZ abcdefghijklmnpqrstuvwxyz", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize23, - 1u, - 10u, - positions23 - }, - - { - "EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR MIDDLE", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize24, - 2u, - 22u, - positions24 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR MIDDLE", - "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" , - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize25, - 3u, - 24u, - positions25 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR MIDDLE", - "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" , - true, - DevelText::LineWrap::CHARACTER, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize26, - 3u, - 36u, - positions26 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR MIDDLE", - "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" , - true, - DevelText::LineWrap::HYPHENATION, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize27, - 3u, - 27u, - positions27 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR MIDDLE", - "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" , - true, - DevelText::LineWrap::MIXED, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize28, - 3u, - 24u, - positions28 - }, - -//MIDDLE RTL cases - { - "EllipsisPosition: TextLabel: SingleLine RTL MIDDLE", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize29, - 1u, - 13u, - positions29 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL MIDDLE", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize30, - 3u, - 31u, - positions30 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL MIDDLE", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::CHARACTER, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize31, - 3u, - 29u, - positions31 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL MIDDLE", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::HYPHENATION, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize32, - 3u, - 31u, - positions32 - }, - - { - "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL MIDDLE", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - true, - DevelText::LineWrap::MIXED, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize33, - 3u, - 31u, - positions33 - }, - - { - "EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR END", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize34, - 1u, - 13u, - positions34 - }, - - { - "EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR START", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize35, - 1u, - 11u, - positions35 - }, - - { - "EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR MIDDLE", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - true, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize36, - 1u, - 12u, - positions36 - }, - - }; - const unsigned int numberOfTests = 39u; - - for( unsigned int index = 0u; index < numberOfTests; ++index ) - { - ToolkitTestApplication application; - if( !ElideTestViewModel( data[index] ) ) - { - tet_result(TET_FAIL); - } - } - - tet_result(TET_PASS); - END_TEST; -} - - -int UtcDaliTextFieldlElideTextLocation(void) -{ - tet_infoline(" UtcDaliTextFieldlElideTextLocation "); - - Size textSize00( 100.f, 100.f ); - - Size textSize01( 120.0f, 50.0f ); - float positions01[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 50.0f, 60.0f, 70.0f, 80.0f, 91.0f }; - - Size textSize02( 120.0f, 50.0f ); - float positions02[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f, 59.0f, 65.0f, 73.0f, 84.0f, 93.0f }; - - Size textSize03( 120.0f, 50.0f ); - float positions03[] = { 117.0f, 111.0f, 97.0f, 88.0f, 80.0f, 74.0f, 64.0f, 59.0f, 54.0f, 45.0f, 37.0f, 31.0f, 22.0f, 7.0f }; - - Size textSize04( 120.0f, 50.0f ); - float positions04[] = { 5.0f, 21.0f, 31.0f, 41.0f, 50.0f, 61.0f, 71.0f, 80.0f, 90.0f, 100.0f, 109.0f }; - - Size textSize05( 120.0f, 50.0f ); - float positions05[] = { 8.0f, 24.0f, 35.0f, 44.0f, 49.0f, 63.0f, 74.0f, 77.0f, 85.0f, 96.0f, 110.0f }; - - Size textSize06( 120.0f, 50.0f ); - float positions06[] = { 90.0f, 79.0f, 70.0f, 68.0f, 62.0f, 56.0f, 51.0f, 42.0f, 29.0f, 26.0f, 15.0f, 7.0f, 0.0f }; - - Size textSize07( 120.0f, 50.0f ); - float positions07[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 53.0f }; - - Size textSize08( 120.0f, 50.0f ); - float positions08[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f }; - - Size textSize09( 120.0f, 50.0f ); - float positions09[] = { 116.0f, 109.0f, 96.0f, 87.0f, 79.0f, 73.0f, 63.0f }; - - Size textSize10( 120.0f, 50.0f ); - float positions10[] = { 121.0f, 116.0f, 111.0f, 106.0f, 101.0f, 96.0f, 92.0f, 87.0f, 83.0f, 77.0f, 63.0f, 55.0f, 46.0f, 40.0f, 30.0f, 16.0f }; - - Size textSize11( 120.0f, 50.0f ); - float positions11[] = { 93.0f, 77.0f, 74.0f, 63.0f, 56.0f, 49.0f, 44.0f, 39.0f, 34.0f, 29.0f, 24.0f, 19.0f, 14.0f, 9.0f, 5.0f }; - - Size textSize12( 120.0f, 50.0f ); - float positions12[] = { 117.0f, 112.0f, 107.0f, 102.0f, 97.0f, 92.0f, 87.0f, 82.0f, 79.0f, 72.0f }; - - struct ElideData data[] = - { - { - "void text", - "", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize00, - 0u, - 0u, - nullptr - }, - - { - "void text", - "", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize00, - 0u, - 0u, - nullptr - }, - - { - "void text", - "", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize00, - 0u, - 0u, - nullptr - }, - - { - "EllipsisPosition: TextField: Basic case SingleLine LTR END", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize01, - 1u, - 10u, - positions01 - }, - - { - "EllipsisPosition: TextField: SingleLine LTR END", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize02, - 1u, - 13u, - positions02 - }, - - { - "EllipsisPosition: TextField: SingleLine RTL END", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize03, - 1u, - 14u, - positions03 - }, - - { - "EllipsisPosition: TextField: Basic case SingleLine LTR START", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize04, - 1u, - 11u, - positions04 - }, - - { - "EllipsisPosition: TextField: SingleLine LTR START", - "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" , - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize05, - 1u, - 11u, - positions05 - }, - - { - "EllipsisPosition: TextField: SingleLine RTL START", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize06, - 1u, - 13u, - positions06 - }, - - { - "EllipsisPosition: TextField: Basic case SingleLine LTR MIDDLE", - "A0123456789 B0123456789 C0123456789 D0123456789 ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize07, - 1u, - 11u, - positions07 - }, - - { - "EllipsisPosition: TextField: SingleLine LTR MIDDLE", - "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" , - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize08, - 1u, - 13u, - positions08 - }, - - { - "EllipsisPosition: TextField: SingleLine RTL MIDDLE", - "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize09, - 1u, - 13u, - positions09 - }, - - { - "EllipsisPosition: TextField: Head and Tail whitespaces RTL END", - " السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::END, - false, - textSize10, - 1u, - 16u, - positions10 - }, - - { - "EllipsisPosition: TextField: Head and Tail whitespaces RTL START", - " السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::START, - false, - textSize11, - 1u, - 15u, - positions11 - }, - - { - "EllipsisPosition: TextField: Head and Tail whitespaces RTL MIDDLE", - " السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة ", - false, - DevelText::LineWrap::WORD, - DevelText::EllipsisPosition::MIDDLE, - false, - textSize12, - 1u, - 20u, - positions12 - }, - - }; - - const unsigned int numberOfTests = 15u; + {"void text", + "", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize00, + 0u, + 0u, + nullptr}, + + {"void text", + "", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize00, + 0u, + 0u, + nullptr}, + + {"void text", + "", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize00, + 0u, + 0u, + nullptr}, + + {"EllipsisPosition: TextField: Basic case SingleLine LTR END", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize01, + 1u, + 10u, + positions01}, + + {"EllipsisPosition: TextField: SingleLine LTR END", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize02, + 1u, + 13u, + positions02}, + + {"EllipsisPosition: TextField: SingleLine RTL END", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize03, + 1u, + 14u, + positions03}, + + {"EllipsisPosition: TextField: Basic case SingleLine LTR START", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize04, + 1u, + 11u, + positions04}, + + {"EllipsisPosition: TextField: SingleLine LTR START", + "Hello Hi Experimen Welcome Hello Hi Experimen Welcome", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize05, + 1u, + 11u, + positions05}, + + {"EllipsisPosition: TextField: SingleLine RTL START", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize06, + 1u, + 13u, + positions06}, + + {"EllipsisPosition: TextField: Basic case SingleLine LTR MIDDLE", + "A0123456789 B0123456789 C0123456789 D0123456789 ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize07, + 1u, + 11u, + positions07}, + + {"EllipsisPosition: TextField: SingleLine LTR MIDDLE", + "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize08, + 1u, + 13u, + positions08}, + + {"EllipsisPosition: TextField: SingleLine RTL MIDDLE", + "السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize09, + 1u, + 13u, + positions09}, + + {"EllipsisPosition: TextField: Head and Tail whitespaces RTL END", + " السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize10, + 1u, + 16u, + positions10}, + + {"EllipsisPosition: TextField: Head and Tail whitespaces RTL START", + " السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize11, + 1u, + 15u, + positions11}, + + {"EllipsisPosition: TextField: Head and Tail whitespaces RTL MIDDLE", + " السلام عليكم مرحبا اهلا هذا اختبار شكرا للمساعدة ", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::MIDDLE, + false, + textSize12, + 1u, + 20u, + positions12}, + + {"EllipsisPosition: TextField: Mixed Directions Languages END", + "سیٹنگیں Projector سیٹنگیں", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::END, + false, + textSize13, + 1u, + 16, + positions13}, + + {"EllipsisPosition: TextField: Mixed Directions Languages START", + "سیٹنگیں Projector سیٹنگیں", + false, + DevelText::LineWrap::WORD, + DevelText::EllipsisPosition::START, + false, + textSize14, + 1u, + 17, + positions14}, + + }; + + const unsigned int numberOfTests = 17u; 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 f02bb95..9cfba93 100644 --- a/dali-toolkit/internal/text/rendering/view-model.cpp +++ b/dali-toolkit/internal/text/rendering/view-model.cpp @@ -524,7 +524,71 @@ void ViewModel::ElideGlyphs() // Change the 'x' and 'y' position of the ellipsis glyph. if(position.x > firstPenX) { - position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + if(isTailMode) + { + // To handle case of the mixed languages (LTR then RTL) with + // EllipsisPosition::END and the LayoutDirection::RIGHT_TO_LEFT + float nextXPositions = ellipsisLine->width; + if(indexOfEllipsis + 1u < numberOfGlyphs) + { + Vector2& positionOfNextGlyph = *(elidedPositionsBuffer + indexOfEllipsis + 1u); + nextXPositions = positionOfNextGlyph.x; + } + + if(position.x > nextXPositions) // RTL language + { + if((indexOfEllipsis > 0u) && ((position.x - nextXPositions) > removedGlypsWidth)) + { + // To handle mixed directions + // Re-calculates the first penX which will be used if rtl text is elided. + firstPenX = position.x - glyphToRemove.xBearing; + if(firstPenX < -ellipsisGlyph.xBearing) + { + // Avoids to exceed the bounding box when rtl text is elided. + firstPenX = -ellipsisGlyph.xBearing; + } + //Reset the width of removed glyphs + removedGlypsWidth = std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)) - ellipsisGlyph.xBearing; + + --indexOfEllipsis; + continue; + } + else + { + // To handle the case of RTL language with EllipsisPosition::END + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + } + } + else + { + // To handle the case of LTR language with EllipsisPosition::START + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + } + else + { + if(!isTailMode) + { + // To handle case of the mixed languages (RTL then LTR) with + // EllipsisPosition::START and the LayoutDirection::RIGHT_TO_LEFT + float nextXPositions = ellipsisLine->width; + if(indexOfEllipsis + 1u < numberOfGlyphs) + { + Vector2& positionOfNextGlyph = *(elidedPositionsBuffer + indexOfEllipsis + 1u); + nextXPositions = positionOfNextGlyph.x; + } + + if(position.x < nextXPositions) // LTR language + { + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + + if((position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) > nextXPositions) + { + position.x -= (position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) - nextXPositions; + } + } + } } position.x += ellipsisGlyph.xBearing; diff --git a/dali-toolkit/internal/text/text-view.cpp b/dali-toolkit/internal/text/text-view.cpp index 9c067de..0be5ac6 100644 --- a/dali-toolkit/internal/text/text-view.cpp +++ b/dali-toolkit/internal/text/text-view.cpp @@ -376,10 +376,73 @@ Length View::GetGlyphs(GlyphInfo* glyphs, glyphInfo = ellipsisGlyph; // Change the 'x' and 'y' position of the ellipsis glyph. - if(position.x > firstPenX) { - position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + if(isTailMode) + { + // To handle case of the mixed languages (LTR then RTL) with + // EllipsisPosition::END and the LayoutDirection::RIGHT_TO_LEFT + float nextXPositions = ellipsisLine->width; + if(indexOfEllipsis + 1u < numberOfGlyphs) + { + Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u); + nextXPositions = positionOfNextGlyph.x; + } + + if(position.x > nextXPositions) // RTL language + { + if((indexOfEllipsis > 0u) && ((position.x - nextXPositions) > removedGlypsWidth)) + { + // To handle mixed directions + // Re-calculates the first penX which will be used if rtl text is elided. + firstPenX = position.x - glyphToRemove.xBearing; + if(firstPenX < -ellipsisGlyph.xBearing) + { + // Avoids to exceed the bounding box when rtl text is elided. + firstPenX = -ellipsisGlyph.xBearing; + } + //Reset the width of removed glyphs + removedGlypsWidth = std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)) - ellipsisGlyph.xBearing; + + --indexOfEllipsis; + continue; + } + else + { + // To handle the case of RTL language with EllipsisPosition::END + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + } + } + else + { + // To handle the case of LTR language with EllipsisPosition::START + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + } + } + else + { + if(!isTailMode) + { + // To handle case of the mixed languages (RTL then LTR) with + // EllipsisPosition::START and the LayoutDirection::RIGHT_TO_LEFT + float nextXPositions = ellipsisLine->width; + if(indexOfEllipsis + 1u < numberOfGlyphs) + { + Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u); + nextXPositions = positionOfNextGlyph.x; + } + + if(position.x < nextXPositions) // LTR language + { + position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth; + + if((position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) > nextXPositions) + { + position.x -= (position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) - nextXPositions; + } + } + } } position.x += ellipsisGlyph.xBearing; -- 2.7.4