Merge "Sync test-application" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / multi-language-support-impl.cpp
index a0e6ae5..82470f8 100644 (file)
@@ -228,7 +228,8 @@ void MultilanguageSupport::SetScripts(const Vector<Character>& text,
       // 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)
+      // ZWJ, ZWNJ between emojis should be treated as EMOJI.
+      if(TextAbstraction::EMOJI == currentScriptRun.script && !(TextAbstraction::IsZeroWidthJoiner(character) || TextAbstraction::IsZeroWidthNonJoiner(character)))
       {
         // Emojis doesn't mix well with characters common to all scripts. Insert the emoji run.
         scripts.Insert(scripts.Begin() + scriptIndex, currentScriptRun);
@@ -444,7 +445,8 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
   Vector<ScriptRun>::ConstIterator scriptRunEndIt          = scripts.End();
   bool                             isNewParagraphCharacter = false;
 
-  bool isPreviousEmojiScript = false;
+  bool   isPreviousEmojiScript = false;
+  FontId previousEmojiFontId   = 0u;
 
   CharacterIndex lastCharacter = startIndex + numberOfCharacters;
   for(Length index = startIndex; index < lastCharacter; ++index)
@@ -535,6 +537,16 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
       currentFontRun.isBoldRequired                  = false;
     }
 
+    // ZWJ, ZWNJ between emojis should use the previous emoji font.
+    if(isEmojiScript && (TextAbstraction::IsZeroWidthJoiner(character) || TextAbstraction::IsZeroWidthNonJoiner(character)))
+    {
+      if(0u != previousEmojiFontId)
+      {
+        fontId      = previousEmojiFontId;
+        isValidFont = true;
+      }
+    }
+
     // If the given font is not valid, it means either:
     // - there is no cached font for the current script yet or,
     // - the user has set a different font than the default one for the current script or,
@@ -647,6 +659,15 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
       }   // !isValidFont (2)
     }     // !isValidFont (1)
 
+    // Store the font id when the first character is an emoji.
+    if(isEmojiScript && !isPreviousEmojiScript)
+    {
+      if(0u != fontId)
+      {
+        previousEmojiFontId = fontId;
+      }
+    }
+
 #ifdef DEBUG_ENABLED
     {
       Dali::TextAbstraction::FontDescription description;