{
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 );
+ controller->FontStyleSetByString( true );
+
+ }
+ else
+ {
+ map = value.Get<Property::Map>();
+ controller->FontStyleSetByString( false );
+ }
if( !map.Empty() )
{
if( controller )
{
const bool isDefaultStyle = FontStyle::DEFAULT == type;
+ const bool isSetbyString = controller->IsFontStyleSetByString();
bool weightDefined = false;
bool widthDefined = false;
}
}
- if( weightDefined || widthDefined || slantDefined )
+ if( !isSetbyString )
{
- std::string styleString("{");
+ Property::Map map;
+
if( weightDefined )
{
if( TextAbstraction::FontWeight::NONE != weight )
{
const std::string weightStr( GetEnumerationName( weight,
- FONT_WEIGHT_STRING_TABLE,
- FONT_WEIGHT_STRING_TABLE_COUNT ) );
+ FONT_WEIGHT_STRING_TABLE,
+ FONT_WEIGHT_STRING_TABLE_COUNT ) );
- styleString += "\"weight\":\"" + weightStr + "\"";
- }
- else
- {
- weightDefined = false;
+ map.Insert( WEIGHT_KEY, weightStr );
}
}
FONT_WIDTH_STRING_TABLE,
FONT_WIDTH_STRING_TABLE_COUNT ) );
- if( weightDefined )
- {
- styleString += ",";
- }
- styleString += "\"width\":\"" + widthStr + "\"";
- }
- else
- {
- widthDefined = false;
+ map.Insert( WIDTH_KEY, widthStr );
}
}
FONT_SLANT_STRING_TABLE,
FONT_SLANT_STRING_TABLE_COUNT ) );
- if( weightDefined || widthDefined )
- {
- styleString += ",";
- }
- styleString += "\"slant\":\"" + slantStr + "\"";
+ map.Insert( SLANT_KEY, slantStr );
}
- else
+ }
+
+ value = map;
+ } // SetbyMAP
+ else
+ {
+ std::string fontStyleProperties = "{";
+
+ if( weightDefined )
+ {
+ if( TextAbstraction::FontWeight::NONE != weight )
{
- slantDefined = false;
+ const std::string weightStr( GetEnumerationName( weight,
+ FONT_WEIGHT_STRING_TABLE,
+ FONT_WEIGHT_STRING_TABLE_COUNT ) );
+
+ fontStyleProperties += "\"weight\":\"" + weightStr + "\",";
}
}
- if( weightDefined || widthDefined || slantDefined )
+ if( widthDefined )
{
- styleString += "}";
+ if( TextAbstraction::FontWidth::NONE != width )
+ {
+ const std::string widthStr( GetEnumerationName( width,
+ FONT_WIDTH_STRING_TABLE,
+ FONT_WIDTH_STRING_TABLE_COUNT ) );
+ fontStyleProperties += "\"width\":\"" + widthStr + "\",";
+ }
}
- else
+
+ if( slantDefined )
{
- styleString.clear();
+ if( TextAbstraction::FontSlant::NONE != slant )
+ {
+ const std::string slantStr( GetEnumerationName( slant,
+ FONT_SLANT_STRING_TABLE,
+ FONT_SLANT_STRING_TABLE_COUNT ) );
+
+ fontStyleProperties += "\"slant\":\"" + slantStr + "\"";
+ }
}
- value = styleString;
- }
- }
+ // If last character is comma, it will be removed.
+ if((*fontStyleProperties.rbegin()) == ',' )
+ {
+ fontStyleProperties = fontStyleProperties.substr( 0, fontStyleProperties.size()-1 );
+ }
+ fontStyleProperties += "}";
+
+ value = fontStyleProperties;
+ } // SetbyString
+ }// controller
}
FontWeight StringToWeight( const char* const weightStr )