Add fallback font find condition. 28/317928/3
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 04:28:15 +0000 (13:28 +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 4729c52e3f3089d9c6c2e3788dec3f873ba12342..3cf9bdb797cc75c737315ccb64239166eecda2fc 100644 (file)
@@ -63,10 +63,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, ...)
 
@@ -179,6 +180,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
 
@@ -200,7 +215,6 @@ bool ValidateFontsPerScript::IsValidFont(FontId fontId) const
 void ValidateFontsPerScript::Cache(FontId fontId)
 {
   mValidFonts.PushBack(fontId);
-
   return;
 }
 
@@ -778,6 +792,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;
 
@@ -788,7 +817,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))
     {