Fix for multi-language support.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / multi-language-support-impl.cpp
index f251025..c596045 100644 (file)
@@ -26,7 +26,7 @@
 #include <dali/public-api/text-abstraction/script.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/logical-model.h>
+#include <dali-toolkit/internal/text/logical-model-impl.h>
 #include <dali-toolkit/internal/text/font-run.h>
 #include <dali-toolkit/internal/text/script-run.h>
 #include <dali-toolkit/internal/text/text-io.h>
@@ -450,12 +450,33 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
       {
         // Check in the valid fonts cache.
         ValidateFontsPerScript* validateFontsPerScript = *( validFontsPerScriptCacheBuffer + script );
+
+        if( NULL == validateFontsPerScript )
+        {
+          validateFontsPerScript = new ValidateFontsPerScript();
+
+          mValidFontsPerScriptCache.PushBack( validateFontsPerScript );
+          validFontsPerScriptCacheBuffer = mValidFontsPerScriptCache.Begin();
+        }
+
         if( NULL != validateFontsPerScript )
         {
           if( !validateFontsPerScript->FindValidFont( fontId ) )
           {
             // Use the font client to validate the font.
-            const GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
+            GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
+
+            // Emojis are present in many monochrome fonts; prefer color by default.
+            if( TextAbstraction::EMOJI == script &&
+                0u != glyphIndex )
+            {
+              BufferImage bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
+              if( bitmap &&
+                  Pixel::BGRA8888 != bitmap.GetPixelFormat() )
+              {
+                glyphIndex = 0;
+              }
+            }
 
             if( 0u == glyphIndex )
             {
@@ -472,28 +493,6 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
             }
           }
         }
-        else
-        {
-          // Use the font client to validate the font.
-          const GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
-
-          if( 0u == glyphIndex )
-          {
-            // Get the point size of the current font. It will be used to get a default font id.
-            pointSize = fontClient.GetPointSize( fontId );
-
-            // The font is not valid. Set to zero and a default one will be set.
-            fontId = 0u;
-          }
-          else if( !IsValidForAllScripts( character ) )
-          {
-            // Add the font to the valid font cache.
-            validateFontsPerScript = new ValidateFontsPerScript();
-            *( validFontsPerScriptCacheBuffer + script ) = validateFontsPerScript;
-
-            validateFontsPerScript->mValidFonts.PushBack( fontId );
-          }
-        }
       }
     } // !isDefault