X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Fdali-toolkit-test-utils%2Ftoolkit-text-utils.cpp;h=b2a6f5ae7daa966eae5c72d31dce151f0a096aa7;hp=16666e9e357fcc63559fbe4d0d21112c56545d1a;hb=7c96cf0cba486c3167af95f787e35d51a2ce94e6;hpb=2c41553e8144b52da80b174939367a34ac2a871d diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp index 16666e9..b2a6f5a 100755 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ #include #include #include +#include namespace Dali { @@ -100,7 +101,8 @@ void CreateTextModel( const std::string& text, Size& layoutSize, ModelPtr& textModel, MetricsPtr& metrics, - bool markupProcessorEnabled ) + bool markupProcessorEnabled, + LineWrap::Mode wrapMode ) { textModel = Model::New(); ///< Pointer to the text's model. LogicalModelPtr logicalModel = textModel->mLogicalModel; @@ -108,7 +110,10 @@ void CreateTextModel( const std::string& text, MarkupProcessData markupProcessData( logicalModel->mColorRuns, logicalModel->mFontDescriptionRuns, - logicalModel->mEmbeddedItems ); + logicalModel->mEmbeddedItems, + logicalModel->mAnchors, + logicalModel->mUnderlinedCharacterRuns, + logicalModel->mBackgroundColorRuns); Length textSize = 0u; const uint8_t* utf8 = NULL; @@ -152,6 +157,41 @@ void CreateTextModel( const std::string& text, return; } + textModel->mLineWrapMode = wrapMode; + + if(textModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::HYPHENATION) || + textModel->mLineWrapMode == ((Text::LineWrap::Mode)DevelText::LineWrap::MIXED)) + { + CharacterIndex end = characterCount; + LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin(); + + for(CharacterIndex index = 0; index < end; index++) + { + CharacterIndex wordEnd = index; + while((*(lineBreakInfoBuffer + wordEnd) != TextAbstraction::LINE_ALLOW_BREAK) && (*(lineBreakInfoBuffer + wordEnd) != TextAbstraction::LINE_MUST_BREAK)) + { + wordEnd++; + } + + if((wordEnd + 1) == end) // add last char + { + wordEnd++; + } + + Vector hyphens = GetWordHyphens(utf32Characters.Begin() + index, wordEnd - index, nullptr); + + for(CharacterIndex i = 0; i < (wordEnd - index); i++) + { + if(hyphens[i]) + { + *(lineBreakInfoBuffer + index + i) = TextAbstraction::LINE_HYPHENATION_BREAK; + } + } + + index = wordEnd; + } + } + // 3) Set the script info. MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get(); @@ -282,9 +322,7 @@ void CreateTextModel( const std::string& text, // Set the layout parameters. textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN; - textModel->mLineWrapMode = LineWrap::WORD; textModel->mIgnoreSpacesAfterText = true; - textModel->mMatchSystemLanguageDirection = false; Layout::Parameters layoutParameters( textArea, textModel ); @@ -303,42 +341,10 @@ void CreateTextModel( const std::string& text, bool isAutoScroll = false; layoutEngine.LayoutText( layoutParameters, - glyphPositions, - lines, layoutSize, false, isAutoScroll ); - // 10) Reorder the lines - if( 0u != bidirectionalInfo.Count() ) - { - Vector& bidirectionalLineInfo = logicalModel->mBidirectionalLineInfo; - - // Get the lines - const Length numberOfLines = lines.Count(); - - // Reorder the lines. - bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters. - ReorderLines( bidirectionalInfo, - 0u, - characterCount, - lines, - bidirectionalLineInfo ); - - // Set the bidirectional info per line into the layout parameters. - layoutParameters.lineBidirectionalInfoRunsBuffer = bidirectionalLineInfo.Begin(); - layoutParameters.numberOfBidirectionalInfoRuns = bidirectionalLineInfo.Count(); - - if( options.reorder ) - { - // Re-layout the text. Reorder those lines with right to left characters. - layoutEngine.ReLayoutRightToLeftLines( layoutParameters, - 0u, - characterCount, - glyphPositions ); - } - } - if( options.align ) { float alignmentOffset = 0.f; @@ -376,6 +382,9 @@ void ConfigureTextLabel( ControllerPtr controller ) // Enable the text elide. controller->SetTextElideEnabled( true ); + + // Disable match system language direction + controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS); } void ConfigureTextField( ControllerPtr controller ) @@ -405,6 +414,9 @@ void ConfigureTextField( ControllerPtr controller ) // Disable the text elide. controller->SetTextElideEnabled( false ); + + // Disable match system language direction + controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS); } void ConfigureTextEditor( ControllerPtr controller ) @@ -434,6 +446,9 @@ void ConfigureTextEditor( ControllerPtr controller ) // Disable the text elide. controller->SetTextElideEnabled( false ); + + // Disable match system language direction + controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS); } } // namespace Text