Provided color-conversion helpers
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-font-style.cpp
index b3b9e84..6a57337 100644 (file)
@@ -108,12 +108,17 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu
 {
   if( controller )
   {
-    const std::string style = value.Get< std::string >();
-    DALI_LOG_INFO( gLogFilter, Debug::General, "Text Control %p FONT_STYLE %s\n", controller.Get(), style.c_str() );
-
-    // Parses and applies the style.
     Property::Map map;
-    ParsePropertyString( style, map );
+    if( Property::STRING == value.GetType() )
+    {
+      const std::string& fontStyleProperties = value.Get<std::string>();
+
+      ParsePropertyString( fontStyleProperties, map );
+    }
+    else
+    {
+      map = value.Get<Property::Map>();
+    }
 
     if( !map.Empty() )
     {
@@ -289,76 +294,45 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon
       }
     }
 
-    if( weightDefined || widthDefined || slantDefined )
+    Property::Map map;
+
+    if( weightDefined )
     {
-      std::string styleString("{");
-      if( weightDefined )
+      if( TextAbstraction::FontWeight::NONE != weight )
       {
-        if( TextAbstraction::FontWeight::NONE != weight )
-        {
-          const std::string weightStr( GetEnumerationName( weight,
-                                                           FONT_WEIGHT_STRING_TABLE,
-                                                           FONT_WEIGHT_STRING_TABLE_COUNT ) );
+        const std::string weightStr( GetEnumerationName( weight,
+                                                         FONT_WEIGHT_STRING_TABLE,
+                                                         FONT_WEIGHT_STRING_TABLE_COUNT ) );
 
-          styleString += "\"weight\":\"" + weightStr + "\"";
-        }
-        else
-        {
-          weightDefined = false;
-        }
+        map.Insert( WEIGHT_KEY, weightStr );
       }
+    }
 
-      if( widthDefined )
+    if( widthDefined )
+    {
+      if( TextAbstraction::FontWidth::NONE != width )
       {
-        if( TextAbstraction::FontWidth::NONE != width )
-        {
-          const std::string widthStr( GetEnumerationName( width,
-                                                          FONT_WIDTH_STRING_TABLE,
-                                                          FONT_WIDTH_STRING_TABLE_COUNT ) );
+        const std::string widthStr( GetEnumerationName( width,
+                                                        FONT_WIDTH_STRING_TABLE,
+                                                        FONT_WIDTH_STRING_TABLE_COUNT ) );
 
-          if( weightDefined )
-          {
-            styleString += ",";
-          }
-          styleString += "\"width\":\"" + widthStr + "\"";
-        }
-        else
-        {
-          widthDefined = false;
-        }
+        map.Insert( WIDTH_KEY, widthStr );
       }
+    }
 
-      if( slantDefined )
+    if( slantDefined )
+    {
+      if( TextAbstraction::FontSlant::NONE != slant )
       {
-        if( TextAbstraction::FontSlant::NONE != slant )
-        {
-          const std::string slantStr( GetEnumerationName( slant,
-                                                          FONT_SLANT_STRING_TABLE,
-                                                          FONT_SLANT_STRING_TABLE_COUNT ) );
-
-          if( weightDefined || widthDefined )
-          {
-            styleString += ",";
-          }
-          styleString += "\"slant\":\"" + slantStr + "\"";
-        }
-        else
-        {
-          slantDefined = false;
-        }
-      }
+        const std::string slantStr( GetEnumerationName( slant,
+                                                        FONT_SLANT_STRING_TABLE,
+                                                        FONT_SLANT_STRING_TABLE_COUNT ) );
 
-      if( weightDefined || widthDefined || slantDefined )
-      {
-        styleString += "}";
+        map.Insert( SLANT_KEY, slantStr );
       }
-      else
-      {
-        styleString.clear();
-      }
-
-      value = styleString;
     }
+
+    value = map;
   }
 }