From 300570df779616fb1538174d8b6f1b43514122eb Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Fri, 7 Dec 2018 18:03:59 +0900 Subject: [PATCH] bug fixed about the rtl markup behavior. ex) TextLabel label = TextLabel::New("‏20‏/‏11‏/‏2018‏" ); or TextLabel label = TextLabel::New("‏20&‏/‏11‏/‏2018‏"); should be displayed not "20/11/2018" but "2018/11/20" refer) https://www.w3schools.com/cssref/tryit.asp?filename=trycss_text_direction Change-Id: Iab595aedc691afbfd53f4b75c5eab4d58b26b59f --- dali-toolkit/internal/text/bidirectional-support.cpp | 2 +- dali-toolkit/internal/text/multi-language-support-impl.cpp | 12 +++++++++++- dali-toolkit/internal/text/script-run.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) mode change 100644 => 100755 dali-toolkit/internal/text/script-run.h diff --git a/dali-toolkit/internal/text/bidirectional-support.cpp b/dali-toolkit/internal/text/bidirectional-support.cpp index 9f9bddc..26e99b7 100755 --- a/dali-toolkit/internal/text/bidirectional-support.cpp +++ b/dali-toolkit/internal/text/bidirectional-support.cpp @@ -148,7 +148,7 @@ void SetBidirectionalInfo( const Vector& text, break; } - if( !hasRightToLeftScript && TextAbstraction::IsRightToLeftScript( scriptRun.script ) ) + if( !hasRightToLeftScript && scriptRun.isRightToLeft ) { // The script is right to left. hasRightToLeftScript = true; diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 4b6eee2..607d159 100755 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -204,6 +204,9 @@ void MultilanguageSupport::SetScripts( const Vector& text, // Pointers to the text buffer. const Character* const textBuffer = text.Begin(); + // Initialize whether is right to left direction + currentScriptRun.isRightToLeft = false; + // Traverse all characters and set the scripts. const Length lastCharacter = startIndex + numberOfCharacters; for( Length index = startIndex; index < lastCharacter; ++index ) @@ -226,6 +229,9 @@ void MultilanguageSupport::SetScripts( const Vector& text, while( !endOfText && ( TextAbstraction::COMMON == script ) ) { + // Check if whether is right to left markup and Keeps true if the previous value was true. + currentScriptRun.isRightToLeft = currentScriptRun.isRightToLeft || TextAbstraction::IsRightToLeftMark( character ); + if( TextAbstraction::EMOJI == currentScriptRun.script ) { // Emojis doesn't mix well with characters common to all scripts. Insert the emoji run. @@ -262,6 +268,8 @@ void MultilanguageSupport::SetScripts( const Vector& text, currentScriptRun.characterRun.numberOfCharacters = 0u; currentScriptRun.script = TextAbstraction::UNKNOWN; numberOfAllScriptCharacters = 0u; + // Initialize whether is right to left direction + currentScriptRun.isRightToLeft = false; } // Get the next character. @@ -288,7 +296,7 @@ void MultilanguageSupport::SetScripts( const Vector& text, ( TextAbstraction::EMOJI != script ) ) { // Sets the direction of the first valid script. - isParagraphRTL = TextAbstraction::IsRightToLeftScript( script ); + isParagraphRTL = currentScriptRun.isRightToLeft || TextAbstraction::IsRightToLeftScript( script ); isFirstScriptToBeSet = false; } @@ -332,6 +340,8 @@ void MultilanguageSupport::SetScripts( const Vector& text, currentScriptRun.characterRun.numberOfCharacters = numberOfAllScriptCharacters + 1u; // Adds the white spaces which are at the begining of the script. currentScriptRun.script = script; numberOfAllScriptCharacters = 0u; + // Check if whether is right to left script. + currentScriptRun.isRightToLeft = TextAbstraction::IsRightToLeftScript( currentScriptRun.script ); } else { diff --git a/dali-toolkit/internal/text/script-run.h b/dali-toolkit/internal/text/script-run.h old mode 100644 new mode 100755 index 3533df6..3f6b678 --- a/dali-toolkit/internal/text/script-run.h +++ b/dali-toolkit/internal/text/script-run.h @@ -37,6 +37,7 @@ struct ScriptRun { CharacterRun characterRun; ///< The initial character index and the number of characters of the run. Script script; ///< Script of the run. + bool isRightToLeft; ///< Whether is right to left direction }; } // namespace Text -- 2.7.4