X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fmulti-language-support-impl.cpp;h=81d815c91fea0c93440df498521bda10fbf0528b;hb=e5d379064ba0e9a68d1d2680906952dbde263f34;hp=4b6eee2e26566edd9cae0c2e0295edaf9e890f28;hpb=b85254b482e88b8f05b66e3656a1a29a7a7ea5fa;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 4b6eee2..81d815c 100755 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -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 { @@ -425,6 +435,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, currentFontRun.characterRun.characterIndex = startIndex; currentFontRun.characterRun.numberOfCharacters = 0u; currentFontRun.fontId = 0u; + currentFontRun.isBoldRequired = false; + currentFontRun.isItalicRequired = false; // Get the font client. TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); @@ -438,16 +450,13 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, bool isPreviousEmojiScript = false; - // Description of fallback font which is selected at current iteration. - TextAbstraction::FontDescription selectedFontDescription; - CharacterIndex lastCharacter = startIndex + numberOfCharacters; for( Length index = startIndex; index < lastCharacter; ++index ) { // Get the current character. const Character character = *( textBuffer + index ); - bool needSoftwareBoldening = false; - bool needSoftwareItalic = false; + bool isItalicRequired = false; + bool isBoldRequired = false; // new description for current character TextAbstraction::FontDescription currentFontDescription; @@ -526,6 +535,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters; currentFontRun.characterRun.numberOfCharacters = 0u; currentFontRun.fontId = fontId; + currentFontRun.isItalicRequired = false; + currentFontRun.isBoldRequired = false; } // If the given font is not valid, it means either: @@ -666,22 +677,17 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, } #endif - if( fontId != currentFontRun.fontId ) - { - fontClient.GetDescription(fontId,selectedFontDescription); - } - - // Developer sets bold to character but selected font cannot support it - needSoftwareBoldening = ( currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD ) && ( selectedFontDescription.weight < TextAbstraction::FontWeight::BOLD ); + // Whether bols style is required. + isBoldRequired = ( currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD ); - // Developer sets italic to character but selected font cannot support it - needSoftwareItalic = ( currentFontDescription.slant == TextAbstraction::FontSlant::ITALIC ) && ( selectedFontDescription.slant < TextAbstraction::FontSlant::ITALIC ); + // Whether italic style is required. + isItalicRequired = ( currentFontDescription.slant >= TextAbstraction::FontSlant::ITALIC ); // The font is now validated. if( ( fontId != currentFontRun.fontId ) || isNewParagraphCharacter || // If font id is same as previous but style is diffrent, initialize new one - ( ( fontId == currentFontRun.fontId ) && ( ( needSoftwareBoldening != currentFontRun.softwareBold ) || ( needSoftwareItalic != currentFontRun.softwareItalic ) ) ) ) + ( ( fontId == currentFontRun.fontId ) && ( ( isBoldRequired != currentFontRun.isBoldRequired ) || ( isItalicRequired != currentFontRun.isItalicRequired ) ) ) ) { // Current run needs to be stored and a new one initialized. @@ -696,8 +702,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters; currentFontRun.characterRun.numberOfCharacters = 0u; currentFontRun.fontId = fontId; - currentFontRun.softwareItalic = needSoftwareItalic; - currentFontRun.softwareBold = needSoftwareBoldening; + currentFontRun.isBoldRequired = isBoldRequired; + currentFontRun.isItalicRequired = isItalicRequired; } // Add one more character to the run.