Fix access out of bounds in the text's multi-language support.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / multi-language-support-impl.cpp
index ae9a68b..fd1d8e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -477,9 +477,9 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
     currentFontId = fontId;
 
     // Get the script for the current character.
-    const Script script = GetScript( index,
-                                     scriptRunIt,
-                                     scriptRunEndIt );
+    Script script = GetScript( index,
+                               scriptRunIt,
+                               scriptRunEndIt );
 
 #ifdef DEBUG_ENABLED
     {
@@ -494,6 +494,10 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
                      description.path.c_str() );
     }
 #endif
+    if (script == TextAbstraction::UNKNOWN)
+    {
+      script = TextAbstraction::LATIN;
+    }
 
     // Validate whether the current character is supported by the given font.
     bool isValidFont = false;
@@ -565,7 +569,6 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
           // At this point the character common for all scripts has no font assigned.
           // If there is a valid previously cached default font for it, use that one.
           fontId = cachedDefaultFontId;
-          isValidFont = true;
         }
       }
       else
@@ -590,10 +593,8 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
           if( isValidFont &&
               isEmojiScript )
           {
-            const PixelData bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
-
-            // For color emojis, the font is valid if the bitmap is RGBA.
-            isValidFont = bitmap && ( Pixel::BGRA8888 == bitmap.GetPixelFormat() );
+            // For color emojis, the font is valid if the glyph is a color glyph (the bitmap is RGBA).
+            isValidFont = fontClient.IsColorGlyph( fontId, glyphIndex );
           }
 
           // If there is a valid font, cache it.