X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-font-style.cpp;h=249157e3563d358bc23fd65ca66c4fc12da180db;hp=6a573373417e554486c06696e61566be4df755c6;hb=8177827cf40d243367b4c92ea8d5e3c40d42f3ae;hpb=1b19b2081740d17668cb240015ca42dac0d31eda diff --git a/dali-toolkit/internal/text/text-font-style.cpp b/dali-toolkit/internal/text/text-font-style.cpp index 6a57337..249157e 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -114,10 +114,13 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu const std::string& fontStyleProperties = value.Get(); ParsePropertyString( fontStyleProperties, map ); + controller->FontStyleSetByString( true ); + } else { map = value.Get(); + controller->FontStyleSetByString( false ); } if( !map.Empty() ) @@ -243,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; @@ -294,46 +298,97 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon } } - Property::Map map; - - if( weightDefined ) + if( !isSetbyString ) { - if( TextAbstraction::FontWeight::NONE != weight ) + Property::Map map; + + if( weightDefined ) { - const std::string weightStr( GetEnumerationName( weight, - FONT_WEIGHT_STRING_TABLE, - FONT_WEIGHT_STRING_TABLE_COUNT ) ); + if( TextAbstraction::FontWeight::NONE != weight ) + { + const std::string weightStr( GetEnumerationName( weight, + FONT_WEIGHT_STRING_TABLE, + FONT_WEIGHT_STRING_TABLE_COUNT ) ); - map.Insert( WEIGHT_KEY, weightStr ); + map.Insert( WEIGHT_KEY, weightStr ); + } } - } - if( widthDefined ) - { - if( TextAbstraction::FontWidth::NONE != width ) + if( widthDefined ) + { + if( TextAbstraction::FontWidth::NONE != width ) + { + const std::string widthStr( GetEnumerationName( width, + FONT_WIDTH_STRING_TABLE, + FONT_WIDTH_STRING_TABLE_COUNT ) ); + + map.Insert( WIDTH_KEY, widthStr ); + } + } + + if( slantDefined ) { - const std::string widthStr( GetEnumerationName( width, - FONT_WIDTH_STRING_TABLE, - FONT_WIDTH_STRING_TABLE_COUNT ) ); + if( TextAbstraction::FontSlant::NONE != slant ) + { + const std::string slantStr( GetEnumerationName( slant, + FONT_SLANT_STRING_TABLE, + FONT_SLANT_STRING_TABLE_COUNT ) ); - map.Insert( WIDTH_KEY, widthStr ); + map.Insert( SLANT_KEY, slantStr ); + } } - } - if( slantDefined ) + value = map; + } // SetbyMAP + else { - if( TextAbstraction::FontSlant::NONE != slant ) + std::string fontStyleProperties = "{"; + + if( weightDefined ) { - const std::string slantStr( GetEnumerationName( slant, - FONT_SLANT_STRING_TABLE, - FONT_SLANT_STRING_TABLE_COUNT ) ); + if( TextAbstraction::FontWeight::NONE != weight ) + { + const std::string weightStr( GetEnumerationName( weight, + FONT_WEIGHT_STRING_TABLE, + FONT_WEIGHT_STRING_TABLE_COUNT ) ); - map.Insert( SLANT_KEY, slantStr ); + fontStyleProperties += "\"weight\":\"" + weightStr + "\","; + } } - } - value = map; - } + if( widthDefined ) + { + if( TextAbstraction::FontWidth::NONE != width ) + { + const std::string widthStr( GetEnumerationName( width, + FONT_WIDTH_STRING_TABLE, + FONT_WIDTH_STRING_TABLE_COUNT ) ); + fontStyleProperties += "\"width\":\"" + widthStr + "\","; + } + } + + if( slantDefined ) + { + if( TextAbstraction::FontSlant::NONE != slant ) + { + const std::string slantStr( GetEnumerationName( slant, + FONT_SLANT_STRING_TABLE, + FONT_SLANT_STRING_TABLE_COUNT ) ); + + fontStyleProperties += "\"slant\":\"" + slantStr + "\""; + } + } + + // 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 )