From: dongsug.song Date: Tue, 15 Nov 2016 02:49:28 +0000 (+0900) Subject: Revert "[3.0] Retrieve the input font's style." X-Git-Tag: accepted/tizen/common/20161115.200851~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F57%2F97757%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Revert "[3.0] Retrieve the input font's style." This reverts commit 63895ce4e045f84feb76aee76f0b9b790a5c404a. Change-Id: I637852413331bf91a0cacd57826f5c9b89f64cba --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index dfc5c86..2300b50 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -314,19 +314,11 @@ int UtcDaliTextEditorSetPropertyP(void) // Check font properties. editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" ); DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION ); - editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION ); + editor.SetProperty( TextEditor::Property::FONT_STYLE, "Setting font style" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::FONT_STYLE ), std::string("Setting font style"), TEST_LOCATION ); editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f ); DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - // Reset font style. - editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION ); - editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"slant\":\"roman\"}" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION ); - editor.SetProperty( TextEditor::Property::FONT_STYLE, "" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::FONT_STYLE ), std::string(""), TEST_LOCATION ); - // Check that the Alignment properties can be correctly set editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" ); DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION ); @@ -387,19 +379,11 @@ int UtcDaliTextEditorSetPropertyP(void) // Check input font properties. editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" ); DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION ); - editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION ); + editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "Setting input font style" ); + DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_FONT_STYLE ), "Setting input font style", TEST_LOCATION ); editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f ); DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - // Reset input font style. - editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION ); - editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"slant\":\"roman\"}" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION ); - editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "" ); - DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION ); - // Check the line spacing property DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index cd3985a..911a06e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -456,19 +456,11 @@ int UtcDaliTextFieldSetPropertyP(void) // Check font properties. field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION ); - field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION ); + field.SetProperty( TextField::Property::FONT_STYLE, "Setting font style" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string("Setting font style"), TEST_LOCATION ); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - // Reset font style. - field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::FONT_STYLE, "{\"slant\":\"roman\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::FONT_STYLE, "" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string(""), TEST_LOCATION ); - // Check that the MAX_LENGTH property can be correctly set const int maxNumberOfCharacters = 20; field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters ); @@ -553,19 +545,11 @@ int UtcDaliTextFieldSetPropertyP(void) // Check input font properties. field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION ); + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "Setting input font style" ); + DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), "Setting input font style", TEST_LOCATION ); field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - // Reset input font style. - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"slant\":\"roman\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION ); - // Check the underline property field.SetProperty( TextField::Property::UNDERLINE, "Underline properties" ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION ); @@ -1285,10 +1269,10 @@ int utcDaliTextFieldEvent08(void) END_TEST; } -int utcDaliTextFieldStyleWhilstSelected(void) +int utcDaliTextFieldStyleWhilstSelected09(void) { ToolkitTestApplication application; - tet_infoline(" utcDaliTextFieldStyleWhilstSelected"); + tet_infoline(" utcDaliTextFieldEvent09"); // Change font and styles whilst text is selected whilst word selected diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 39778f7..2f71832 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2014 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -193,19 +193,11 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) // Check font properties. label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" ); DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION ); - label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION ); + label.SetProperty( TextLabel::Property::FONT_STYLE, "Setting font style" ); + DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_STYLE ), std::string("Setting font style"), TEST_LOCATION ); label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f ); DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - // Reset font style. - label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION ); - label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"slant\":\"roman\"}" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION ); - label.SetProperty( TextLabel::Property::FONT_STYLE, "" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_STYLE ), std::string(""), TEST_LOCATION ); - // Toggle multi-line label.SetProperty( TextLabel::Property::MULTI_LINE, true ); DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION ); diff --git a/dali-toolkit/internal/text/input-style.h b/dali-toolkit/internal/text/input-style.h index 63add2d..30ce38c 100644 --- a/dali-toolkit/internal/text/input-style.h +++ b/dali-toolkit/internal/text/input-style.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_TEXT_INPUT_STYLE_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ struct InputStyle { InputStyle() : textColor( Color::BLACK ), + fontStyle(), familyName(), weight( TextAbstraction::FontWeight::NORMAL ), width( TextAbstraction::FontWidth::NORMAL ), @@ -63,6 +64,7 @@ struct InputStyle {}; Vector4 textColor; ///< The text's color. + std::string fontStyle; ///< The font's style string. std::string familyName; ///< The font's family name. FontWeight weight; ///< The font's weight. FontWidth width; ///< The font's width. diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index b220be6..8e9ab39 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -166,6 +166,7 @@ struct FontDefaults { FontDefaults() : mFontDescription(), + mFontStyle(), mDefaultPointSize( 0.f ), mFontId( 0u ), familyDefined( false ), @@ -191,6 +192,7 @@ struct FontDefaults } TextAbstraction::FontDescription mFontDescription; ///< The default font's description. + std::string mFontStyle; ///< The font's style string set through the property system. float mDefaultPointSize; ///< The default font's point size. FontId mFontId; ///< The font's id of the default font. bool familyDefined:1; ///< Whether the default font's family name is defined. diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index dbbf523..f6544cb 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -446,6 +446,26 @@ const std::string& Controller::GetDefaultFontFamily() const return EMPTY_STRING; } +void Controller::SetDefaultFontStyle( const std::string& style ) +{ + if( NULL == mImpl->mFontDefaults ) + { + mImpl->mFontDefaults = new FontDefaults(); + } + + mImpl->mFontDefaults->mFontStyle = style; +} + +const std::string& Controller::GetDefaultFontStyle() const +{ + if( NULL != mImpl->mFontDefaults ) + { + return mImpl->mFontDefaults->mFontStyle; + } + + return EMPTY_STRING; +} + void Controller::SetDefaultFontWeight( FontWeight weight ) { if( NULL == mImpl->mFontDefaults ) @@ -462,11 +482,6 @@ void Controller::SetDefaultFontWeight( FontWeight weight ) mImpl->RequestRelayout(); } -bool Controller::IsDefaultFontWeightDefined() const -{ - return mImpl->mFontDefaults->weightDefined; -} - FontWeight Controller::GetDefaultFontWeight() const { if( NULL != mImpl->mFontDefaults ) @@ -493,11 +508,6 @@ void Controller::SetDefaultFontWidth( FontWidth width ) mImpl->RequestRelayout(); } -bool Controller::IsDefaultFontWidthDefined() const -{ - return mImpl->mFontDefaults->widthDefined; -} - FontWidth Controller::GetDefaultFontWidth() const { if( NULL != mImpl->mFontDefaults ) @@ -524,11 +534,6 @@ void Controller::SetDefaultFontSlant( FontSlant slant ) mImpl->RequestRelayout(); } -bool Controller::IsDefaultFontSlantDefined() const -{ - return mImpl->mFontDefaults->slantDefined; -} - FontSlant Controller::GetDefaultFontSlant() const { if( NULL != mImpl->mFontDefaults ) @@ -950,6 +955,25 @@ const std::string& Controller::GetInputFontFamily() const return GetDefaultFontFamily(); } +void Controller::SetInputFontStyle( const std::string& fontStyle ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mInputStyle.fontStyle = fontStyle; + } +} + +const std::string& Controller::GetInputFontStyle() const +{ + if( NULL != mImpl->mEventData ) + { + return mImpl->mEventData->mInputStyle.fontStyle; + } + + // Return the default font's style if there is no EventData. + return GetDefaultFontStyle(); +} + void Controller::SetInputFontWeight( FontWeight weight ) { if( NULL != mImpl->mEventData ) @@ -994,18 +1018,6 @@ void Controller::SetInputFontWeight( FontWeight weight ) } } -bool Controller::IsInputFontWeightDefined() const -{ - bool defined = false; - - if( NULL != mImpl->mEventData ) - { - defined = mImpl->mEventData->mInputStyle.weightDefined; - } - - return defined; -} - FontWeight Controller::GetInputFontWeight() const { if( NULL != mImpl->mEventData ) @@ -1060,18 +1072,6 @@ void Controller::SetInputFontWidth( FontWidth width ) } } -bool Controller::IsInputFontWidthDefined() const -{ - bool defined = false; - - if( NULL != mImpl->mEventData ) - { - defined = mImpl->mEventData->mInputStyle.widthDefined; - } - - return defined; -} - FontWidth Controller::GetInputFontWidth() const { if( NULL != mImpl->mEventData ) @@ -1126,18 +1126,6 @@ void Controller::SetInputFontSlant( FontSlant slant ) } } -bool Controller::IsInputFontSlantDefined() const -{ - bool defined = false; - - if( NULL != mImpl->mEventData ) - { - defined = mImpl->mEventData->mInputStyle.slantDefined; - } - - return defined; -} - FontSlant Controller::GetInputFontSlant() const { if( NULL != mImpl->mEventData ) diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 7b1e2ba..ad5c09a 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_TEXT_CONTROLLER_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -305,16 +305,27 @@ public: const std::string& GetDefaultFontFamily() const; /** - * @brief Sets the default font weight. + * @brief Sets the font's style string. * - * @param[in] weight The font weight. + * @note The style set may be changed by the underlying font system. The string is stored to be recovered. + * + * @param[in] style The font's style string. */ - void SetDefaultFontWeight( FontWeight weight ); + void SetDefaultFontStyle( const std::string& style ); /** - * @brief Whether the font's weight has been defined. + * @brief Retrieves the font's style. + * + * @return The font's style. + */ + const std::string& GetDefaultFontStyle() const; + + /** + * @brief Sets the default font weight. + * + * @param[in] weight The font weight. */ - bool IsDefaultFontWeightDefined() const; + void SetDefaultFontWeight( FontWeight weight ); /** * @brief Retrieves the default font weight. @@ -331,11 +342,6 @@ public: void SetDefaultFontWidth( FontWidth width ); /** - * @brief Whether the font's width has been defined. - */ - bool IsDefaultFontWidthDefined() const; - - /** * @brief Retrieves the default font width. * * @return The default font width. @@ -350,11 +356,6 @@ public: void SetDefaultFontSlant( FontSlant slant ); /** - * @brief Whether the font's slant has been defined. - */ - bool IsDefaultFontSlantDefined() const; - - /** * @brief Retrieves the default font slant. * * @return The default font slant. @@ -586,16 +587,25 @@ public: const std::string& GetInputFontFamily() const; /** - * @brief Sets the input font's weight. + * @brief Sets the input text's font style. * - * @param[in] weight The input font's weight. + * @param[in] fontStyle The input text's font style. */ - void SetInputFontWeight( FontWeight weight ); + void SetInputFontStyle( const std::string& fontStyle ); /** - * @return Whether the font's weight has been defined. + * @brief Retrieves the input text's font style. + * + * @return The input text's font style. */ - bool IsInputFontWeightDefined() const; + const std::string& GetInputFontStyle() const; + + /** + * @brief Sets the input font's weight. + * + * @param[in] weight The input font's weight. + */ + void SetInputFontWeight( FontWeight weight ); /** * @brief Retrieves the input font's weight. @@ -612,11 +622,6 @@ public: void SetInputFontWidth( FontWidth width ); /** - * @return Whether the font's width has been defined. - */ - bool IsInputFontWidthDefined() const; - - /** * @brief Retrieves the input font's width. * * @return The input font's width. @@ -631,11 +636,6 @@ public: void SetInputFontSlant( FontSlant slant ); /** - * @return Whether the font's slant has been defined. - */ - bool IsInputFontSlantDefined() const; - - /** * @brief Retrieves the input font's slant. * * @return The input font's slant. diff --git a/dali-toolkit/internal/text/text-font-style.cpp b/dali-toolkit/internal/text/text-font-style.cpp index 6fff87e..190a3f3 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -53,6 +53,22 @@ 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 ); @@ -150,7 +166,7 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu } break; } - } // switch + } } // map not empty else { @@ -170,136 +186,27 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu controller->SetInputFontSlant( TextAbstraction::FontSlant::NONE ); break; } - } // switch - } // map.Empty() - } // controller + } + } + } } void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type ) { if( controller ) { - 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 + switch( type ) { - weightDefined = controller->IsInputFontWeightDefined(); - widthDefined = controller->IsInputFontWidthDefined(); - slantDefined = controller->IsInputFontSlantDefined(); - - if( weightDefined ) + case FontStyle::DEFAULT: { - weight = controller->GetInputFontWeight(); + value = controller->GetDefaultFontStyle(); + break; } - - if( widthDefined ) + case FontStyle::INPUT: { - width = controller->GetInputFontWidth(); + value = controller->GetInputFontStyle(); + break; } - - if( slantDefined ) - { - slant = controller->GetInputFontSlant(); - } - } - - if( weightDefined || widthDefined || slantDefined ) - { - 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 ) - { - 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; - } - } - - if( weightDefined || widthDefined || slantDefined ) - { - styleString += "}"; - } - else - { - styleString.clear(); - } - - value = styleString; } } }