TextModel - Update only the edited paragraph when the style changes. 05/67005/5
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 12 Apr 2016 15:03:40 +0000 (16:03 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Mon, 25 Apr 2016 09:46:07 +0000 (10:46 +0100)
Change-Id: I5a6666dd2e3f20fc16a786efd43bef2fd766aea0
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/text/multi-language-helper-functions.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller.cpp

index a5feaef..06b0f10 100644 (file)
@@ -43,19 +43,36 @@ void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
   // Pointer to the font id buffer.
   FontId* fontIdsBuffer = fontIds.Begin();
 
   // Pointer to the font id buffer.
   FontId* fontIdsBuffer = fontIds.Begin();
 
+  // Used to temporarily store the style per character.
+  TextAbstraction::FontDescription fontDescription;
+  TextAbstraction::PointSize26Dot6 fontSize;
+
+  Length familyIndex = 0u;
+  Length weightIndex = 0u;
+  Length widthIndex = 0u;
+  Length slantIndex = 0u;
+  Length sizeIndex = 0u;
+
   // Traverse all the characters.
   // Traverse all the characters.
-  for( CharacterIndex index = startIndex; index < numberOfCharacters; ++index )
+  const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
+  for( CharacterIndex index = startIndex; index < lastCharacterPlusOne; ++index )
   {
   {
-    // The default font description and font point size.
-    TextAbstraction::FontDescription fontDescription = defaultFontDescription;
-    TextAbstraction::PointSize26Dot6 fontSize = defaultPointSize;
     bool defaultFont = true;
 
     bool defaultFont = true;
 
+    Length runIndex = 0u;
+
+    bool familyOverriden = false;
+    bool weightOverriden = false;
+    bool widthOverriden = false;
+    bool slantOverriden = false;
+    bool sizeOverriden = false;
+
     // Traverse all the font descriptions.
     // Traverse all the font descriptions.
-    for( Vector<FontDescriptionRun>::ConstIterator it = fontDescriptions.Begin(),
+    const FontDescriptionRun* const fontDescriptionsBuffer = fontDescriptions.Begin();
+    for( Vector<FontDescriptionRun>::ConstIterator it = fontDescriptionsBuffer,
            endIt = fontDescriptions.End();
          it != endIt;
            endIt = fontDescriptions.End();
          it != endIt;
-         ++it )
+         ++it, ++runIndex )
     {
       // Check whether the character's font is modified by the current font description.
       const FontDescriptionRun& fontRun = *it;
     {
       // Check whether the character's font is modified by the current font description.
       const FontDescriptionRun& fontRun = *it;
@@ -64,28 +81,33 @@ void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
       {
         if( fontRun.familyDefined )
         {
       {
         if( fontRun.familyDefined )
         {
-          fontDescription.family = std::string( fontRun.familyName, fontRun.familyLength );
           defaultFont = false;
           defaultFont = false;
+          familyOverriden = true;
+          familyIndex = runIndex;
         }
         if( fontRun.weightDefined )
         {
         }
         if( fontRun.weightDefined )
         {
-          fontDescription.weight = fontRun.weight;
           defaultFont = false;
           defaultFont = false;
+          weightOverriden = true;
+          weightIndex = runIndex;
         }
         if( fontRun.widthDefined )
         {
         }
         if( fontRun.widthDefined )
         {
-          fontDescription.width = fontRun.width;
           defaultFont = false;
           defaultFont = false;
+          widthOverriden = true;
+          widthIndex = runIndex;
         }
         if( fontRun.slantDefined )
         {
         }
         if( fontRun.slantDefined )
         {
-          fontDescription.slant = fontRun.slant;
           defaultFont = false;
           defaultFont = false;
+          slantOverriden = true;
+          slantIndex = runIndex;
         }
         if( fontRun.sizeDefined )
         {
         }
         if( fontRun.sizeDefined )
         {
-          fontSize = fontRun.size;
           defaultFont = false;
           defaultFont = false;
+          sizeOverriden = true;
+          sizeIndex = runIndex;
         }
       }
     }
         }
       }
     }
@@ -93,6 +115,56 @@ void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
     // Get the font id if is not the default font.
     if( !defaultFont )
     {
     // Get the font id if is not the default font.
     if( !defaultFont )
     {
+      if( familyOverriden )
+      {
+        const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + familyIndex );
+        fontDescription.family = std::string( fontRun.familyName, fontRun.familyLength ); // TODO Could use move constructor when switch to c++11.
+      }
+      else
+      {
+        fontDescription.family = defaultFontDescription.family;
+      }
+
+      if( weightOverriden )
+      {
+        const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + weightIndex );
+        fontDescription.weight = fontRun.weight;
+      }
+      else
+      {
+        fontDescription.weight = defaultFontDescription.weight;
+      }
+
+      if( widthOverriden )
+      {
+        const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + widthIndex );
+        fontDescription.width = fontRun.width;
+      }
+      else
+      {
+        fontDescription.width = defaultFontDescription.width;
+      }
+
+      if( slantOverriden )
+      {
+        const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + slantIndex );
+        fontDescription.slant = fontRun.slant;
+      }
+      else
+      {
+        fontDescription.slant = defaultFontDescription.slant;
+      }
+
+      if( sizeOverriden )
+      {
+        const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + sizeIndex );
+        fontSize = fontRun.size;
+      }
+      else
+      {
+        fontSize = defaultPointSize;
+      }
+
       *( fontIdsBuffer + index - startIndex ) = fontClient.GetFontId( fontDescription, fontSize );
     }
   }
       *( fontIdsBuffer + index - startIndex ) = fontClient.GetFontId( fontDescription, fontSize );
     }
   }
index 95266cd..c37c7be 100644 (file)
@@ -896,34 +896,50 @@ void Controller::Impl::RetrieveDefaultInputStyle( InputStyle& inputStyle )
   inputStyle.textColor = mTextColor;
   inputStyle.isDefaultColor = true;
 
   inputStyle.textColor = mTextColor;
   inputStyle.isDefaultColor = true;
 
+  inputStyle.familyName.clear();
+  inputStyle.weight = TextAbstraction::FontWeight::NORMAL;
+  inputStyle.width = TextAbstraction::FontWidth::NORMAL;
+  inputStyle.slant = TextAbstraction::FontSlant::NORMAL;
+  inputStyle.size = 0.f;
+
+  inputStyle.familyDefined = false;
+  inputStyle.weightDefined = false;
+  inputStyle.widthDefined = false;
+  inputStyle.slantDefined = false;
+  inputStyle.sizeDefined = false;
+
   // Sets the default font's family name, weight, width, slant and size.
   if( mFontDefaults )
   {
   // Sets the default font's family name, weight, width, slant and size.
   if( mFontDefaults )
   {
-    inputStyle.familyName = mFontDefaults->mFontDescription.family;
-    inputStyle.weight = mFontDefaults->mFontDescription.weight;
-    inputStyle.width = mFontDefaults->mFontDescription.width;
-    inputStyle.slant = mFontDefaults->mFontDescription.slant;
-    inputStyle.size = mFontDefaults->mDefaultPointSize;
+    if( mFontDefaults->familyDefined )
+    {
+      inputStyle.familyName = mFontDefaults->mFontDescription.family;
+      inputStyle.familyDefined = true;
+    }
 
 
-    inputStyle.familyDefined = mFontDefaults->familyDefined;
-    inputStyle.weightDefined = mFontDefaults->weightDefined;
-    inputStyle.widthDefined = mFontDefaults->widthDefined;
-    inputStyle.slantDefined = mFontDefaults->slantDefined;
-    inputStyle.sizeDefined = mFontDefaults->sizeDefined;
-  }
-  else
-  {
-    inputStyle.familyName.clear();
-    inputStyle.weight = TextAbstraction::FontWeight::NORMAL;
-    inputStyle.width = TextAbstraction::FontWidth::NORMAL;
-    inputStyle.slant = TextAbstraction::FontSlant::NORMAL;
-    inputStyle.size = 0.f;
-
-    inputStyle.familyDefined = false;
-    inputStyle.weightDefined = false;
-    inputStyle.widthDefined = false;
-    inputStyle.slantDefined = false;
-    inputStyle.sizeDefined = false;
+    if( mFontDefaults->weightDefined )
+    {
+      inputStyle.weight = mFontDefaults->mFontDescription.weight;
+      inputStyle.weightDefined = true;
+    }
+
+    if( mFontDefaults->widthDefined )
+    {
+      inputStyle.width = mFontDefaults->mFontDescription.width;
+      inputStyle.widthDefined = true;
+    }
+
+    if( mFontDefaults->slantDefined )
+    {
+      inputStyle.slant = mFontDefaults->mFontDescription.slant;
+      inputStyle.slantDefined = true;
+    }
+
+    if( mFontDefaults->sizeDefined )
+    {
+      inputStyle.size = mFontDefaults->mDefaultPointSize;
+      inputStyle.sizeDefined = true;
+    }
   }
 }
 
   }
 }
 
index 0ea1d70..c92aab8 100644 (file)
@@ -68,15 +68,19 @@ namespace Text
  *
  * @param[in] eventData The event data pointer.
  * @param[in] logicalModel The logical model where to add the new font description run.
  *
  * @param[in] eventData The event data pointer.
  * @param[in] logicalModel The logical model where to add the new font description run.
+ * @param[out] startOfSelectedText Index to the first selected character.
+ * @param[out] lengthOfSelectedText Number of selected characters.
  */
 FontDescriptionRun& UpdateSelectionFontStyleRun( EventData* eventData,
  */
 FontDescriptionRun& UpdateSelectionFontStyleRun( EventData* eventData,
-                                                 LogicalModelPtr logicalModel )
+                                                 LogicalModelPtr logicalModel,
+                                                 CharacterIndex& startOfSelectedText,
+                                                 Length& lengthOfSelectedText )
 {
   const bool handlesCrossed = eventData->mLeftSelectionPosition > eventData->mRightSelectionPosition;
 
   // Get start and end position of selection
 {
   const bool handlesCrossed = eventData->mLeftSelectionPosition > eventData->mRightSelectionPosition;
 
   // Get start and end position of selection
-  const CharacterIndex startOfSelectedText = handlesCrossed ? eventData->mRightSelectionPosition : eventData->mLeftSelectionPosition;
-  const Length lengthOfSelectedText = ( handlesCrossed ? eventData->mLeftSelectionPosition : eventData->mRightSelectionPosition ) - startOfSelectedText;
+  startOfSelectedText = handlesCrossed ? eventData->mRightSelectionPosition : eventData->mLeftSelectionPosition;
+  lengthOfSelectedText = ( handlesCrossed ? eventData->mLeftSelectionPosition : eventData->mRightSelectionPosition ) - startOfSelectedText;
 
   // Add the font run.
   const VectorBase::SizeType numberOfRuns = logicalModel->mFontDescriptionRuns.Count();
 
   // Add the font run.
   const VectorBase::SizeType numberOfRuns = logicalModel->mFontDescriptionRuns.Count();
@@ -115,8 +119,6 @@ void Controller::SetGlyphType( TextAbstraction::GlyphType glyphType )
   // Clear the font-specific data
   ClearFontData();
 
   // Clear the font-specific data
   ClearFontData();
 
-  mImpl->mRecalculateNaturalSize = true;
-
   mImpl->RequestRelayout();
 }
 
   mImpl->RequestRelayout();
 }
 
@@ -323,8 +325,6 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
   // Clear the font-specific data
   ClearFontData();
 
   // Clear the font-specific data
   ClearFontData();
 
-  mImpl->mRecalculateNaturalSize = true;
-
   mImpl->RequestRelayout();
 }
 
   mImpl->RequestRelayout();
 }
 
@@ -371,8 +371,6 @@ void Controller::SetDefaultFontWeight( FontWeight weight )
   // Clear the font-specific data
   ClearFontData();
 
   // Clear the font-specific data
   ClearFontData();
 
-  mImpl->mRecalculateNaturalSize = true;
-
   mImpl->RequestRelayout();
 }
 
   mImpl->RequestRelayout();
 }
 
@@ -399,8 +397,6 @@ void Controller::SetDefaultFontWidth( FontWidth width )
   // Clear the font-specific data
   ClearFontData();
 
   // Clear the font-specific data
   ClearFontData();
 
-  mImpl->mRecalculateNaturalSize = true;
-
   mImpl->RequestRelayout();
 }
 
   mImpl->RequestRelayout();
 }
 
@@ -427,8 +423,6 @@ void Controller::SetDefaultFontSlant( FontSlant slant )
   // Clear the font-specific data
   ClearFontData();
 
   // Clear the font-specific data
   ClearFontData();
 
-  mImpl->mRecalculateNaturalSize = true;
-
   mImpl->RequestRelayout();
 }
 
   mImpl->RequestRelayout();
 }
 
@@ -464,8 +458,6 @@ void Controller::SetDefaultPointSize( float pointSize )
   // Clear the font-specific data
   ClearFontData();
 
   // Clear the font-specific data
   ClearFontData();
 
-  mImpl->mRecalculateNaturalSize = true;
-
   mImpl->RequestRelayout();
 }
 
   mImpl->RequestRelayout();
 }
 
@@ -486,9 +478,10 @@ void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
   if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
   {
     DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
   if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
   {
     DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
-    ClearFontData();
     mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
     mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
-    mImpl->mRecalculateNaturalSize = true;
+
+    ClearFontData();
+
     mImpl->RequestRelayout();
   }
 }
     mImpl->RequestRelayout();
   }
 }
@@ -720,8 +713,12 @@ void Controller::SetInputFontFamily( const std::string& fontFamily )
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
+      CharacterIndex startOfSelectedText = 0u;
+      Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel );
+                                                                            mImpl->mLogicalModel,
+                                                                            startOfSelectedText,
+                                                                            lengthOfSelectedText );
 
       fontDescriptionRun.familyLength = fontFamily.size();
       fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
 
       fontDescriptionRun.familyLength = fontFamily.size();
       fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
@@ -731,10 +728,21 @@ void Controller::SetInputFontFamily( const std::string& fontFamily )
       // The memory allocated for the font family name is freed when the font description is removed from the logical model.
 
       // Request to relayout.
       // The memory allocated for the font family name is freed when the font description is removed from the logical model.
 
       // Request to relayout.
-      mImpl->mOperationsPending = ALL_OPERATIONS;
+      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+                                                               VALIDATE_FONTS            |
+                                                               SHAPE_TEXT                |
+                                                               GET_GLYPH_METRICS         |
+                                                               LAYOUT                    |
+                                                               UPDATE_ACTUAL_SIZE        |
+                                                               REORDER                   |
+                                                               ALIGN );
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
+      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
       // As the font changes, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
       // As the font changes, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@ -782,17 +790,32 @@ void Controller::SetInputFontWeight( FontWeight weight )
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
+      CharacterIndex startOfSelectedText = 0u;
+      Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel );
+                                                                            mImpl->mLogicalModel,
+                                                                            startOfSelectedText,
+                                                                            lengthOfSelectedText );
 
       fontDescriptionRun.weight = weight;
       fontDescriptionRun.weightDefined = true;
 
       // Request to relayout.
 
       fontDescriptionRun.weight = weight;
       fontDescriptionRun.weightDefined = true;
 
       // Request to relayout.
-      mImpl->mOperationsPending = ALL_OPERATIONS;
+      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+                                                               VALIDATE_FONTS            |
+                                                               SHAPE_TEXT                |
+                                                               GET_GLYPH_METRICS         |
+                                                               LAYOUT                    |
+                                                               UPDATE_ACTUAL_SIZE        |
+                                                               REORDER                   |
+                                                               ALIGN );
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
+      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@ -820,17 +843,32 @@ void Controller::SetInputFontWidth( FontWidth width )
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
+      CharacterIndex startOfSelectedText = 0u;
+      Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel );
+                                                                            mImpl->mLogicalModel,
+                                                                            startOfSelectedText,
+                                                                            lengthOfSelectedText );
 
       fontDescriptionRun.width = width;
       fontDescriptionRun.widthDefined = true;
 
       // Request to relayout.
 
       fontDescriptionRun.width = width;
       fontDescriptionRun.widthDefined = true;
 
       // Request to relayout.
-      mImpl->mOperationsPending = ALL_OPERATIONS;
+      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+                                                               VALIDATE_FONTS            |
+                                                               SHAPE_TEXT                |
+                                                               GET_GLYPH_METRICS         |
+                                                               LAYOUT                    |
+                                                               UPDATE_ACTUAL_SIZE        |
+                                                               REORDER                   |
+                                                               ALIGN );
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
+      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@ -858,17 +896,32 @@ void Controller::SetInputFontSlant( FontSlant slant )
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
+      CharacterIndex startOfSelectedText = 0u;
+      Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel );
+                                                                            mImpl->mLogicalModel,
+                                                                            startOfSelectedText,
+                                                                            lengthOfSelectedText );
 
       fontDescriptionRun.slant = slant;
       fontDescriptionRun.slantDefined = true;
 
       // Request to relayout.
 
       fontDescriptionRun.slant = slant;
       fontDescriptionRun.slantDefined = true;
 
       // Request to relayout.
-      mImpl->mOperationsPending = ALL_OPERATIONS;
+      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+                                                               VALIDATE_FONTS            |
+                                                               SHAPE_TEXT                |
+                                                               GET_GLYPH_METRICS         |
+                                                               LAYOUT                    |
+                                                               UPDATE_ACTUAL_SIZE        |
+                                                               REORDER                   |
+                                                               ALIGN );
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
+      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@ -895,17 +948,32 @@ void Controller::SetInputFontPointSize( float size )
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
 
     if( EventData::SELECTING == mImpl->mEventData->mState )
     {
+      CharacterIndex startOfSelectedText = 0u;
+      Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel );
+                                                                            mImpl->mLogicalModel,
+                                                                            startOfSelectedText,
+                                                                            lengthOfSelectedText );
 
       fontDescriptionRun.size = static_cast<PointSize26Dot6>( size * 64.f );
       fontDescriptionRun.sizeDefined = true;
 
       // Request to relayout.
 
       fontDescriptionRun.size = static_cast<PointSize26Dot6>( size * 64.f );
       fontDescriptionRun.sizeDefined = true;
 
       // Request to relayout.
-      mImpl->mOperationsPending = ALL_OPERATIONS;
+      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+                                                               VALIDATE_FONTS            |
+                                                               SHAPE_TEXT                |
+                                                               GET_GLYPH_METRICS         |
+                                                               LAYOUT                    |
+                                                               UPDATE_ACTUAL_SIZE        |
+                                                               REORDER                   |
+                                                               ALIGN );
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
       mImpl->mRecalculateNaturalSize = true;
       mImpl->RequestRelayout();
 
+      mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+      mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
       // As the font might change, recalculate the handle positions is needed.
       mImpl->mEventData->mUpdateLeftSelectionPosition = true;
       mImpl->mEventData->mUpdateRightSelectionPosition = true;
@@ -2586,13 +2654,16 @@ void Controller::ClearFontData()
   {
     mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
   }
   {
     mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID
   }
-  mImpl->mVisualModel->ClearCaches();
 
 
+  // Set flags to update the model.
   mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
   mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
   mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count();
 
   mImpl->mTextUpdateInfo.mClearAll = true;
   mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
   mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
   mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count();
 
   mImpl->mTextUpdateInfo.mClearAll = true;
+  mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
+  mImpl->mRecalculateNaturalSize = true;
+
   mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
                                                            VALIDATE_FONTS            |
                                                            SHAPE_TEXT                |
   mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
                                                            VALIDATE_FONTS            |
                                                            SHAPE_TEXT                |