Merge "Fix setting a void string to the TEXT property." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller-impl.h
index e60fe37..2936d4d 100644 (file)
@@ -21,7 +21,6 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/devel-api/text-abstraction/font-client.h>
-#include <iostream>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
@@ -175,11 +174,14 @@ struct ModifyEvent
 struct FontDefaults
 {
   FontDefaults()
-  : mDefaultFontFamily(""),
-    mDefaultFontStyle(""),
+  : mFontDescription(),
+    mFontStyle(),
     mDefaultPointSize(0.0f),
     mFontId(0u)
   {
+    // Initially use the default platform font
+    TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+    fontClient.GetDefaultPlatformFontDescription( mFontDescription );
   }
 
   FontId GetFontId( TextAbstraction::FontClient& fontClient )
@@ -187,14 +189,14 @@ struct FontDefaults
     if( !mFontId )
     {
       Dali::TextAbstraction::PointSize26Dot6 pointSize = mDefaultPointSize*64;
-      mFontId = fontClient.GetFontId( mDefaultFontFamily, mDefaultFontStyle, pointSize );
+      mFontId = fontClient.GetFontId( mFontDescription, pointSize );
     }
 
     return mFontId;
   }
 
-  std::string mDefaultFontFamily;
-  std::string mDefaultFontStyle;
+  TextAbstraction::FontDescription mFontDescription;
+  std::string mFontStyle;
   float mDefaultPointSize;
   FontId mFontId;
 };
@@ -218,7 +220,7 @@ struct Controller::Impl
     mOperationsPending( NO_OPERATION ),
     mMaximumNumberOfCharacters( 50 ),
     mRecalculateNaturalSize( true ),
-    mUserDefinedFontFamily( false)
+    mUserDefinedFontFamily( false )
   {
     mLogicalModel = LogicalModel::New();
     mVisualModel  = VisualModel::New();
@@ -320,14 +322,17 @@ struct Controller::Impl
 
   void ResetImfManager()
   {
-    // Reset incase we are in a pre-edit state.
-    ImfManager imfManager = ImfManager::Get();
-    if ( imfManager )
+    if( mEventData )
     {
-      imfManager.Reset(); // Will trigger a commit message
+      // Reset incase we are in a pre-edit state.
+      ImfManager imfManager = ImfManager::Get();
+      if ( imfManager )
+      {
+        imfManager.Reset(); // Will trigger a commit message
+      }
+
+      ClearPreEditFlag();
     }
-
-    ClearPreEditFlag();
   }
 
   bool IsClipboardEmpty()
@@ -488,7 +493,7 @@ struct Controller::Impl
   Length mMaximumNumberOfCharacters;       ///< Maximum number of characters that can be inserted.
 
   bool mRecalculateNaturalSize:1;          ///< Whether the natural size needs to be recalculated.
-  bool mUserDefinedFontFamily:1;           ///< Whether the Font family was Set by the user instead of being left as sytem default
+  bool mUserDefinedFontFamily:1;           ///< Whether the Font family was set by the user instead of being left as sytem default.
 };
 
 } // namespace Text