X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-font-style.cpp;h=6fff87e9e61832665cd1b2e438ef2d9fd5f92339;hb=012328b60466dc0ab4d44336738bf75493c8b3bd;hp=b31decb16b764843cd8924227c6143fd18775518;hpb=39fc99671f79f683a834406e24edf485752c600d;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 b31decb..6fff87e 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -53,22 +53,6 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu 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() ); - switch( type ) - { - case FontStyle::DEFAULT: - { - // Stores the default font's style string to be recovered by the GetFontStyleProperty() function. - controller->SetDefaultFontStyle( style ); - break; - } - case FontStyle::INPUT: - { - // Stores the input font's style string to be recovered by the GetFontStyleProperty() function. - controller->SetInputFontStyle( style ); - break; - } - } - // Parses and applies the style. Property::Map map; ParsePropertyString( style, map ); @@ -78,7 +62,7 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu /// Weight key Property::Value* weightValue = map.Find( WEIGHT_KEY ); - FontWeight weight = TextAbstraction::FontWeight::NORMAL; + FontWeight weight = TextAbstraction::FontWeight::NONE; const bool weightDefined = weightValue != NULL; if( weightDefined ) { @@ -93,7 +77,7 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu /// Width key Property::Value* widthValue = map.Find( WIDTH_KEY ); - FontWidth width = TextAbstraction::FontWidth::NORMAL; + FontWidth width = TextAbstraction::FontWidth::NONE; const bool widthDefined = widthValue != NULL; if( widthDefined ) { @@ -108,7 +92,7 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu /// Slant key Property::Value* slantValue = map.Find( SLANT_KEY ); - FontSlant slant = TextAbstraction::FontSlant::NORMAL; + FontSlant slant = TextAbstraction::FontSlant::NONE; const bool slantDefined = slantValue != NULL; if( slantDefined ) { @@ -125,17 +109,20 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu case FontStyle::DEFAULT: { // Sets the default font's style values. - if( weightDefined && ( controller->GetDefaultFontWeight() != weight ) ) + if( !weightDefined || + ( weightDefined && ( controller->GetDefaultFontWeight() != weight ) ) ) { controller->SetDefaultFontWeight( weight ); } - if( widthDefined && ( controller->GetDefaultFontWidth() != width ) ) + if( !widthDefined || + ( widthDefined && ( controller->GetDefaultFontWidth() != width ) ) ) { controller->SetDefaultFontWidth( width ); } - if( slantDefined && ( controller->GetDefaultFontSlant() != slant ) ) + if( !slantDefined || + ( slantDefined && ( controller->GetDefaultFontSlant() != slant ) ) ) { controller->SetDefaultFontSlant( slant ); } @@ -144,43 +131,175 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu case FontStyle::INPUT: { // Sets the input font's style values. - if( weightDefined && ( controller->GetInputFontWeight() != weight ) ) + if( !weightDefined || + ( weightDefined && ( controller->GetInputFontWeight() != weight ) ) ) { controller->SetInputFontWeight( weight ); } - if( widthDefined && ( controller->GetInputFontWidth() != width ) ) + if( !widthDefined || + ( widthDefined && ( controller->GetInputFontWidth() != width ) ) ) { controller->SetInputFontWidth( width ); } - if( slantDefined && ( controller->GetInputFontSlant() != slant ) ) + if( !slantDefined || + ( slantDefined && ( controller->GetInputFontSlant() != slant ) ) ) { controller->SetInputFontSlant( slant ); } break; } - } - } - } + } // switch + } // map not empty + else + { + switch( type ) + { + case FontStyle::DEFAULT: + { + controller->SetDefaultFontWeight( TextAbstraction::FontWeight::NONE ); + controller->SetDefaultFontWidth( TextAbstraction::FontWidth::NONE ); + controller->SetDefaultFontSlant( TextAbstraction::FontSlant::NONE ); + break; + } + case FontStyle::INPUT: + { + controller->SetInputFontWeight( TextAbstraction::FontWeight::NONE ); + controller->SetInputFontWidth( TextAbstraction::FontWidth::NONE ); + controller->SetInputFontSlant( TextAbstraction::FontSlant::NONE ); + break; + } + } // switch + } // map.Empty() + } // controller } void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type ) { if( controller ) { - switch( type ) + const bool isDefaultStyle = FontStyle::DEFAULT == type; + + bool weightDefined = false; + bool widthDefined = false; + bool slantDefined = false; + FontWeight weight = TextAbstraction::FontWeight::NONE; + FontWidth width = TextAbstraction::FontWidth::NONE; + FontSlant slant = TextAbstraction::FontSlant::NONE; + + if( isDefaultStyle ) + { + weightDefined = controller->IsDefaultFontWeightDefined(); + widthDefined = controller->IsDefaultFontWidthDefined(); + slantDefined = controller->IsDefaultFontSlantDefined(); + + if( weightDefined ) + { + weight = controller->GetDefaultFontWeight(); + } + + if( widthDefined ) + { + width = controller->GetDefaultFontWidth(); + } + + if( slantDefined ) + { + slant = controller->GetDefaultFontSlant(); + } + } + else + { + weightDefined = controller->IsInputFontWeightDefined(); + widthDefined = controller->IsInputFontWidthDefined(); + slantDefined = controller->IsInputFontSlantDefined(); + + if( weightDefined ) + { + weight = controller->GetInputFontWeight(); + } + + if( widthDefined ) + { + width = controller->GetInputFontWidth(); + } + + if( slantDefined ) + { + slant = controller->GetInputFontSlant(); + } + } + + if( weightDefined || widthDefined || slantDefined ) { - case FontStyle::DEFAULT: + std::string styleString("{"); + if( weightDefined ) + { + if( TextAbstraction::FontWeight::NONE != weight ) + { + const std::string weightStr( GetEnumerationName( weight, + FONT_WEIGHT_STRING_TABLE, + FONT_WEIGHT_STRING_TABLE_COUNT ) ); + + styleString += "\"weight\":\"" + weightStr + "\""; + } + else + { + weightDefined = false; + } + } + + if( widthDefined ) + { + if( TextAbstraction::FontWidth::NONE != width ) + { + const std::string widthStr( GetEnumerationName( width, + FONT_WIDTH_STRING_TABLE, + FONT_WIDTH_STRING_TABLE_COUNT ) ); + + if( weightDefined ) + { + styleString += ","; + } + styleString += "\"width\":\"" + widthStr + "\""; + } + else + { + widthDefined = false; + } + } + + if( slantDefined ) { - value = controller->GetDefaultFontStyle(); - break; + 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; + } } - case FontStyle::INPUT: + + if( weightDefined || widthDefined || slantDefined ) { - value = controller->GetInputFontStyle(); - break; + styleString += "}"; } + else + { + styleString.clear(); + } + + value = styleString; } } }