Retrieve the input font's style. 99/81799/6
authorVictor Cebollada <v.cebollada@samsung.com>
Wed, 27 Jul 2016 13:13:04 +0000 (14:13 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Wed, 10 Aug 2016 08:13:20 +0000 (09:13 +0100)
* Removes the font's style string from the InputStyle struct.
  This string is useless as it stores only the string style set
  through the property system. This string does not contain
  the valid font's style if the style changes as a consequence of
  moving the cursor.

Change-Id: I41d05f3686d949e1b50233df7f6d05fc2583af92
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/internal/text/input-style.h
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-font-style.cpp

index 2300b508c6d3811fae1e81f758291cc8ca7d7937..dfc5c8639f25f45d9057c13ed69ee0bf9d3f0992 100644 (file)
@@ -314,11 +314,19 @@ int UtcDaliTextEditorSetPropertyP(void)
   // Check font properties.
   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
-  editor.SetProperty( TextEditor::Property::FONT_STYLE, "Setting font style" );
-  DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE ), std::string("Setting font style"), TEST_LOCATION );
+  editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
+  DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION );
   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
   DALI_TEST_EQUALS( editor.GetProperty<float>( 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<std::string>( 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<std::string>( TextEditor::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
+  editor.SetProperty( TextEditor::Property::FONT_STYLE, "" );
+  DALI_TEST_EQUALS( editor.GetProperty<std::string>( 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<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
@@ -379,11 +387,19 @@ int UtcDaliTextEditorSetPropertyP(void)
   // Check input font properties.
   editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
-  editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "Setting input font style" );
-  DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), "Setting input font style", TEST_LOCATION );
+  editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
+  DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION );
   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
   DALI_TEST_EQUALS( editor.GetProperty<float>( 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<std::string>( 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<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
+  editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "" );
+  DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION );
+
   // Check the line spacing property
   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
index 911a06e9ea22b85c0bb23626bce5bf030e83e8eb..cd3985ae4d16aff045e4cbc6ac336aabf378d43e 100644 (file)
@@ -456,11 +456,19 @@ int UtcDaliTextFieldSetPropertyP(void)
   // Check font properties.
   field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
-  field.SetProperty( TextField::Property::FONT_STYLE, "Setting font style" );
-  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("Setting font style"), TEST_LOCATION );
+  field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
+  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION );
   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
   DALI_TEST_EQUALS( field.GetProperty<float>( 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<std::string>( 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<std::string>( TextField::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
+  field.SetProperty( TextField::Property::FONT_STYLE, "" );
+  DALI_TEST_EQUALS( field.GetProperty<std::string>( 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 );
@@ -545,11 +553,19 @@ int UtcDaliTextFieldSetPropertyP(void)
   // Check input font properties.
   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
-  field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "Setting input font style" );
-  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "Setting input font style", TEST_LOCATION );
+  field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
+  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION );
   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
   DALI_TEST_EQUALS( field.GetProperty<float>( 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<std::string>( 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<std::string>( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
+  field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "" );
+  DALI_TEST_EQUALS( field.GetProperty<std::string>( 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<std::string>( TextField::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION );
@@ -1269,10 +1285,10 @@ int utcDaliTextFieldEvent08(void)
   END_TEST;
 }
 
-int utcDaliTextFieldStyleWhilstSelected09(void)
+int utcDaliTextFieldStyleWhilstSelected(void)
 {
   ToolkitTestApplication application;
-  tet_infoline(" utcDaliTextFieldEvent09");
+  tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
 
   // Change font and styles whilst text is selected whilst word selected
 
index 2f718323b9afa33aa3ead2730bc5a90735b60f3d..39778f7e573f4895c78228d44f7c75eab6f7cdaa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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,11 +193,19 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   // Check font properties.
   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
-  label.SetProperty( TextLabel::Property::FONT_STYLE, "Setting font style" );
-  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE ), std::string("Setting font style"), TEST_LOCATION );
+  label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
+  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION );
   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
   DALI_TEST_EQUALS( label.GetProperty<float>( 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<std::string>( 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<std::string>( TextLabel::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
+  label.SetProperty( TextLabel::Property::FONT_STYLE, "" );
+  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE ), std::string(""), TEST_LOCATION );
+
   // Toggle multi-line
   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
index 30ce38ce760b47be433e2fe23d757ff26f2a5ae6..63add2d26217548ac09bef26d86cbfd94b600bbc 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_TEXT_INPUT_STYLE_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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,7 +40,6 @@ struct InputStyle
 {
   InputStyle()
   : textColor( Color::BLACK ),
-    fontStyle(),
     familyName(),
     weight( TextAbstraction::FontWeight::NORMAL ),
     width( TextAbstraction::FontWidth::NORMAL ),
@@ -64,7 +63,6 @@ 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.
index 8e9ab39be9a48426143b9a11ddde10265373b1cd..b220be6123730c3e0ce039365390ac3ce5a0cdad 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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,7 +166,6 @@ struct FontDefaults
 {
   FontDefaults()
   : mFontDescription(),
-    mFontStyle(),
     mDefaultPointSize( 0.f ),
     mFontId( 0u ),
     familyDefined( false ),
@@ -192,7 +191,6 @@ 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.
index f6544cb3bedff4ebb2f6cdace4909e9587c247d8..dbbf52356da6fa7c65c4f56b4f2e044ae1e20831 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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,26 +446,6 @@ 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 )
@@ -482,6 +462,11 @@ void Controller::SetDefaultFontWeight( FontWeight weight )
   mImpl->RequestRelayout();
 }
 
+bool Controller::IsDefaultFontWeightDefined() const
+{
+  return mImpl->mFontDefaults->weightDefined;
+}
+
 FontWeight Controller::GetDefaultFontWeight() const
 {
   if( NULL != mImpl->mFontDefaults )
@@ -508,6 +493,11 @@ void Controller::SetDefaultFontWidth( FontWidth width )
   mImpl->RequestRelayout();
 }
 
+bool Controller::IsDefaultFontWidthDefined() const
+{
+  return mImpl->mFontDefaults->widthDefined;
+}
+
 FontWidth Controller::GetDefaultFontWidth() const
 {
   if( NULL != mImpl->mFontDefaults )
@@ -534,6 +524,11 @@ void Controller::SetDefaultFontSlant( FontSlant slant )
   mImpl->RequestRelayout();
 }
 
+bool Controller::IsDefaultFontSlantDefined() const
+{
+  return mImpl->mFontDefaults->slantDefined;
+}
+
 FontSlant Controller::GetDefaultFontSlant() const
 {
   if( NULL != mImpl->mFontDefaults )
@@ -955,25 +950,6 @@ 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 )
@@ -1018,6 +994,18 @@ 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 )
@@ -1072,6 +1060,18 @@ 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,6 +1126,18 @@ 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 )
index ad5c09a173c97c396cd97388c4ae736b5da3f9a3..7b1e2ba18c020945145cabbb6b324a04d1b85bef 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_TEXT_CONTROLLER_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -304,22 +304,6 @@ public:
    */
   const std::string& GetDefaultFontFamily() const;
 
-  /**
-   * @brief Sets the font's style string.
-   *
-   * @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 SetDefaultFontStyle( const std::string& style );
-
-  /**
-   * @brief Retrieves the font's style.
-   *
-   * @return The font's style.
-   */
-  const std::string& GetDefaultFontStyle() const;
-
   /**
    * @brief Sets the default font weight.
    *
@@ -327,6 +311,11 @@ public:
    */
   void SetDefaultFontWeight( FontWeight weight );
 
+  /**
+   * @brief Whether the font's weight has been defined.
+   */
+  bool IsDefaultFontWeightDefined() const;
+
   /**
    * @brief Retrieves the default font weight.
    *
@@ -341,6 +330,11 @@ public:
    */
   void SetDefaultFontWidth( FontWidth width );
 
+  /**
+   * @brief Whether the font's width has been defined.
+   */
+  bool IsDefaultFontWidthDefined() const;
+
   /**
    * @brief Retrieves the default font width.
    *
@@ -355,6 +349,11 @@ public:
    */
   void SetDefaultFontSlant( FontSlant slant );
 
+  /**
+   * @brief Whether the font's slant has been defined.
+   */
+  bool IsDefaultFontSlantDefined() const;
+
   /**
    * @brief Retrieves the default font slant.
    *
@@ -586,20 +585,6 @@ public:
    */
   const std::string& GetInputFontFamily() const;
 
-  /**
-   * @brief Sets the input text's font style.
-   *
-   * @param[in] fontStyle The input text's font style.
-   */
-  void SetInputFontStyle( const std::string& fontStyle );
-
-  /**
-   * @brief Retrieves the input text's font style.
-   *
-   * @return The input text's font style.
-   */
-  const std::string& GetInputFontStyle() const;
-
   /**
    * @brief Sets the input font's weight.
    *
@@ -607,6 +592,11 @@ public:
    */
   void SetInputFontWeight( FontWeight weight );
 
+  /**
+   * @return Whether the font's weight has been defined.
+   */
+  bool IsInputFontWeightDefined() const;
+
   /**
    * @brief Retrieves the input font's weight.
    *
@@ -621,6 +611,11 @@ public:
    */
   void SetInputFontWidth( FontWidth width );
 
+  /**
+   * @return Whether the font's width has been defined.
+   */
+  bool IsInputFontWidthDefined() const;
+
   /**
    * @brief Retrieves the input font's width.
    *
@@ -635,6 +630,11 @@ public:
    */
   void SetInputFontSlant( FontSlant slant );
 
+  /**
+   * @return Whether the font's slant has been defined.
+   */
+  bool IsInputFontSlantDefined() const;
+
   /**
    * @brief Retrieves the input font's slant.
    *
index 190a3f346c321f0e30bd6336af0815f6f54cab8a..6fff87e9e61832665cd1b2e438ef2d9fd5f92339 100644 (file)
@@ -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 );
@@ -166,7 +150,7 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu
           }
           break;
         }
-      }
+      } // switch
     } // map not empty
     else
     {
@@ -186,27 +170,136 @@ 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 )
   {
-    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
     {
-      case FontStyle::DEFAULT:
+      weightDefined = controller->IsInputFontWeightDefined();
+      widthDefined = controller->IsInputFontWidthDefined();
+      slantDefined = controller->IsInputFontSlantDefined();
+
+      if( weightDefined )
       {
-        value = controller->GetDefaultFontStyle();
-        break;
+        weight = controller->GetInputFontWeight();
       }
-      case FontStyle::INPUT:
+
+      if( widthDefined )
       {
-        value = controller->GetInputFontStyle();
-        break;
+        width = controller->GetInputFontWidth();
       }
+
+      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;
     }
   }
 }