X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-font-style.cpp;h=249157e3563d358bc23fd65ca66c4fc12da180db;hb=026776eb4b0303604b3c6ca5857cc1ac59b4006e;hp=b3b9e848d051052aad7b04f6e0c067b560ea946a;hpb=754246a1c8812496ac70cdef21c122069ad21640;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-font-style.cpp b/dali-toolkit/internal/text/text-font-style.cpp index b3b9e84..249157e 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -108,12 +108,20 @@ 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(); + + ParsePropertyString( fontStyleProperties, map ); + controller->FontStyleSetByString( true ); + + } + else + { + map = value.Get(); + controller->FontStyleSetByString( false ); + } if( !map.Empty() ) { @@ -238,6 +246,7 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon if( controller ) { const bool isDefaultStyle = FontStyle::DEFAULT == type; + const bool isSetbyString = controller->IsFontStyleSetByString(); bool weightDefined = false; bool widthDefined = false; @@ -289,22 +298,19 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon } } - 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 ); } } @@ -316,15 +322,7 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon FONT_WIDTH_STRING_TABLE, FONT_WIDTH_STRING_TABLE_COUNT ) ); - if( weightDefined ) - { - styleString += ","; - } - styleString += "\"width\":\"" + widthStr + "\""; - } - else - { - widthDefined = false; + map.Insert( WIDTH_KEY, widthStr ); } } @@ -336,30 +334,61 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon 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 )