Revert "[Tizen] Fix ZWJ issue"
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 25 Oct 2023 07:42:42 +0000 (16:42 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 25 Oct 2023 07:42:42 +0000 (16:42 +0900)
This reverts commit 7bff0b52925629229f71f5c03091324221d29bb5.

dali-toolkit/internal/text/controller/text-controller-impl.cpp
dali-toolkit/internal/text/multi-language-support-impl.cpp

index eb85c83..a84509f 100644 (file)
@@ -1305,12 +1305,11 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex(CharacterIndex index) c
 
   if(index < mEventData->mPrimaryCursorPosition)
   {
-    cursorIndex = cursorIndex < numberOfCharacters ? 0u : cursorIndex - numberOfCharacters;
+    cursorIndex -= numberOfCharacters;
   }
   else
   {
-    Length textLength = mModel->mVisualModel->mCharactersToGlyph.Count();
-    cursorIndex = cursorIndex + numberOfCharacters > textLength ? textLength : cursorIndex + numberOfCharacters;
+    cursorIndex += numberOfCharacters;
   }
 
   // Will update the cursor hook position.
index fc3ad67..7b06dee 100644 (file)
@@ -505,6 +505,7 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
   Vector<ScriptRun>::ConstIterator scriptRunEndIt          = scripts.End();
   bool                             isNewParagraphCharacter = false;
 
+  FontId                  previousEmojiFontId = 0u;
   FontId                  currentFontId       = 0u;
   FontId                  previousFontId      = 0u;
   TextAbstraction::Script previousScript      = TextAbstraction::UNKNOWN;
@@ -581,16 +582,15 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
       isValidFont = fontClient.IsCharacterSupportedByFont(fontId, character);
     }
 
-    bool isEmojiScript = IsEmojiColorScript(script) || IsEmojiTextScript(script);
-    bool isZWJ         = TextAbstraction::IsZeroWidthJoiner(character);
+    bool isCommonScript = false;
+    bool isEmojiScript  = TextAbstraction::IsOneOfEmojiScripts(script);
 
-    if((previousScript == script) &&
-       (isEmojiScript || isZWJ))
+    if(isEmojiScript && (previousScript == script))
     {
-      // This sequence should use the previous font.
-      if(0u != previousFontId)
+      // Emoji sequence should use the previous emoji font.
+      if(0u != previousEmojiFontId)
       {
-        fontId      = previousFontId;
+        fontId      = previousEmojiFontId;
         isValidFont = true;
       }
     }
@@ -604,9 +604,6 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
       isValidFont = true;
     }
 
-    // This is valid after CheckFontSupportsCharacter();
-    bool isCommonScript = false;
-
     // 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,
@@ -758,6 +755,19 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
       }
     }
 
+    // Store the font id when the first character is an emoji.
+    if(isEmojiScript)
+    {
+      if(0u != fontId && previousScript != script)
+      {
+        previousEmojiFontId = fontId;
+      }
+    }
+    else
+    {
+      previousEmojiFontId = 0u;
+    }
+
 #ifdef DEBUG_ENABLED
     if(gLogFilter->IsEnabledFor(Debug::Verbose))
     {
@@ -816,7 +826,6 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
     // Whether the current character is a new paragraph character.
     isNewParagraphCharacter = TextAbstraction::IsNewParagraph(character);
     previousScript          = script;
-    currentFontId           = fontId;
     previousFontId          = currentFontId;
   } // end traverse characters.