FindFont with color preference 66/36666/3 new_text_0.1
authorPaul Wisbey <p.wisbey@samsung.com>
Wed, 11 Mar 2015 12:46:57 +0000 (12:46 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 11 Mar 2015 15:20:02 +0000 (15:20 +0000)
Change-Id: I3c3e65306205db7dcedc4a89a6506d434972737b

text/dali/internal/text-abstraction/font-client-impl.cpp
text/dali/internal/text-abstraction/font-client-impl.h
text/dali/internal/text-abstraction/font-client-plugin-impl.cpp
text/dali/internal/text-abstraction/font-client-plugin-impl.h
text/dali/public-api/text-abstraction/font-client.cpp
text/dali/public-api/text-abstraction/font-client.h

index 0471a2a..b749fe9 100644 (file)
@@ -116,11 +116,11 @@ void FontClient::GetSystemFonts( FontList& systemFonts )
   mPlugin->GetSystemFonts( systemFonts );
 }
 
-FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize )
+FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor )
 {
   CreatePlugin();
 
-  return mPlugin->FindDefaultFont( charcode, pointSize );
+  return mPlugin->FindDefaultFont( charcode, pointSize, preferColor );
 }
 
 bool FontClient::IsScalable( const FontPath& path )
index 24b85f0..d3c963c 100644 (file)
@@ -89,7 +89,7 @@ public:
   /**
    * @copydoc Dali::FontClient::FindDefaultFont()
    */
-  FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize );
+  FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor );
 
   /**
    * @copydoc Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
index de95bd1..2b67f41 100644 (file)
@@ -241,8 +241,12 @@ PointSize26Dot6 FontClient::Plugin::GetPointSize( FontId id )
 }
 
 FontId FontClient::Plugin::FindDefaultFont( Character charcode,
-                                            PointSize26Dot6 requestedSize )
+                                            PointSize26Dot6 requestedSize,
+                                            bool preferColor )
 {
+  FontId fontId(0);
+  bool foundColor(false);
+
   // Create the list of default fonts if it has not been created.
   if( mDefaultFonts.empty() )
   {
@@ -253,8 +257,7 @@ FontId FontClient::Plugin::FindDefaultFont( Character charcode,
   // Traverse the list of default fonts.
   // Check for each default font if supports the character.
 
-  for( FontList::const_iterator it = mDefaultFonts.begin(),
-         endIt = mDefaultFonts.end();
+  for( FontList::const_iterator it = mDefaultFonts.begin(), endIt = mDefaultFonts.end();
        it != endIt;
        ++it )
   {
@@ -292,14 +295,30 @@ FontId FontClient::Plugin::FindDefaultFont( Character charcode,
         requestedSize = size;
       }
 
-      return GetFontId( description.family,
-                        description.style,
-                        requestedSize,
-                        0u );
+      fontId = GetFontId( description.family,
+                          description.style,
+                          requestedSize,
+                          0u );
+
+      if( preferColor )
+      {
+        BufferImage bitmap = CreateBitmap( fontId, GetGlyphIndex(fontId,charcode) );
+        if( bitmap &&
+            Pixel::BGRA8888 == bitmap.GetPixelFormat() )
+        {
+          foundColor = true;
+        }
+      }
+
+      // Keep going unless we prefer a different (color) font
+      if( !preferColor || foundColor )
+      {
+        break;
+      }
     }
   }
 
-  return 0u;
+  return fontId;
 }
 
 FontId FontClient::Plugin::GetFontId( const FontPath& path,
index 5885b19..426a59e 100644 (file)
@@ -159,7 +159,7 @@ struct FontClient::Plugin
   /**
    * @copydoc Dali::FontClient::FindDefaultFont()
    */
-  FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize );
+  FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor );
 
   /**
    * @see Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
index f7ddd74..3375dd0 100644 (file)
@@ -84,9 +84,9 @@ PointSize26Dot6 FontClient::GetPointSize( FontId id )
   return GetImplementation(*this).GetPointSize( id );
 }
 
-FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize )
+FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor )
 {
-  return GetImplementation(*this).FindDefaultFont( charcode, pointSize );
+  return GetImplementation(*this).FindDefaultFont( charcode, pointSize, preferColor );
 }
 
 FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
index 42f41c0..4bfb44e 100644 (file)
@@ -159,10 +159,12 @@ public:
    * i.e. when a single default font does not work for all languages.
    * @param[in] charcode The character for which a font is needed.
    * @param[in] pointSize The point size in 26.6 fractional points; the default point size is 12*64.
+   * @param[in] preferColor True if a color font is preferred.
    * @return A valid font ID, or zero if the font does not exist.
    */
   FontId FindDefaultFont( Character charcode,
-                          PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE );
+                          PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE,
+                          bool preferColor = false );
 
   /**
    * @brief Retrieve the unique identifier for a font.