[Tizen] Add fallback font find condition. 58/317958/1
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 10 Jan 2025 03:23:46 +0000 (12:23 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Fri, 10 Jan 2025 06:03:04 +0000 (15:03 +0900)
Add condition for variation cases that do not follow some fallback priorities.

TODO:
We need to import full emoji table to dali for full emoji support.

Change-Id: I9d0da6c079b7df9bdd177a980be610f9e911bd83
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/text/multi-language-support-impl.cpp

index 4e0608ac5b1ad03793691b06c1dceb730e751219..1616e45a58724323e46e0b8e34f4e544cf5e5fc3 100644 (file)
@@ -62,10 +62,11 @@ void CheckFontSupportsCharacter(
   const FontId& cachedDefaultFontId,
   const TextAbstraction::FontDescription& currentFontDescription,
   const TextAbstraction::PointSize26Dot6& currentFontPointSize,
-  DefaultFonts**& defaultFontPerScriptCacheBuffer)
+  DefaultFonts**& defaultFontPerScriptCacheBuffer,
+  bool findFallbackFont)
 {
   // Need to check if the given font supports the current character.
-  if(!isValidFont) // (1)
+  if(!isValidFont && !findFallbackFont) // (1)
   {
     // Whether the current character is common for all scripts (i.e. white spaces, ...)
 
@@ -178,6 +179,20 @@ void CheckFontSupportsCharacter(
       } // !isValidFont (3)
     }   // !isValidFont (2)
   }     // !isValidFont (1)
+  else if(!isValidFont && findFallbackFont)
+  {
+    // Find a fallback-font.
+    fontId = fontClient.FindFallbackFont(character,
+                                         currentFontDescription,
+                                         currentFontPointSize,
+                                         false);
+
+    if(0u == fontId)
+    {
+      fontId = fontClient.FindDefaultFont(character, currentFontPointSize);
+    }
+    isValidFont = true;
+  }
 }
 } // unnamed namespace
 
@@ -199,7 +214,6 @@ bool ValidateFontsPerScript::IsValidFont(FontId fontId) const
 void ValidateFontsPerScript::Cache(FontId fontId)
 {
   mValidFonts.PushBack(fontId);
-
   return;
 }
 
@@ -772,6 +786,21 @@ void MultilanguageSupport::ValidateFonts(TextAbstraction::FontClient&
       isValidFont = true;
     }
 
+    bool findFallbackFont = false;
+    if(TextAbstraction::IsEmojiVariationSequences(character) && !TextAbstraction::IsASCIIDigits(character))
+    {
+      if(index + 1 <= lastCharacter)
+      {
+        const Character nextCharacter = *(textBuffer + index + 1);
+        findFallbackFont = (!TextAbstraction::IsEmojiPresentationSelector(nextCharacter) && !TextAbstraction::IsTextPresentationSelector(nextCharacter) &&
+                            !TextAbstraction::IsZeroWidthJoiner(nextCharacter) && !TextAbstraction::IsEmojiModifier(nextCharacter));
+      }
+      else if(index == lastCharacter)
+      {
+        findFallbackFont = true;
+      }
+    }
+
     // This is valid after CheckFontSupportsCharacter();
     bool isCommonScript = false;
 
@@ -782,7 +811,7 @@ void MultilanguageSupport::ValidateFonts(TextAbstraction::FontClient&
 
     // Need to check if the given font supports the current character.
     CheckFontSupportsCharacter(isValidFont, isCommonScript, character, validFontsPerScriptCacheBuffer, script, fontId, fontClient,
-                               isValidCachedDefaultFont, cachedDefaultFontId, currentFontDescription, currentFontPointSize, defaultFontPerScriptCacheBuffer);
+                               isValidCachedDefaultFont, cachedDefaultFontId, currentFontDescription, currentFontPointSize, defaultFontPerScriptCacheBuffer, findFallbackFont);
 
     if(isEmojiScript && (previousScript != script))
     {