[4.0] clear cache when locale is changed 90/170190/1
authorminho.sun <minho.sun@samsung.com>
Mon, 12 Feb 2018 11:30:15 +0000 (20:30 +0900)
committerminho.sun <minho.sun@samsung.com>
Wed, 14 Feb 2018 06:06:17 +0000 (15:06 +0900)
When locale is change, font configuration might provide a different font
list.

In this case, original cached font might not be valid for same script.
Therefore, we need to clear caches.

Change-Id: Ie4b1b97494bf5bbf24560d690d7d5817afbbefe7
Signed-off-by: minho.sun <minho.sun@samsung.com>
text/dali/devel-api/text-abstraction/font-client.cpp
text/dali/devel-api/text-abstraction/font-client.h
text/dali/internal/text-abstraction/font-client-impl.cpp
text/dali/internal/text-abstraction/font-client-impl.h
text/dali/internal/text-abstraction/font-client-plugin-impl.cpp
text/dali/internal/text-abstraction/font-client-plugin-impl.h
text/dali/internal/text-abstraction/shaping-impl.cpp

index e08cf8b..c303512 100644 (file)
@@ -65,6 +65,11 @@ FontClient& FontClient::operator=( const FontClient& handle )
   return *this;
 }
 
+void FontClient::ClearCache()
+{
+  GetImplementation(*this).ClearCache();
+}
+
 void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi  )
 {
   GetImplementation(*this).SetDpi( horizontalDpi, verticalDpi );
index 951d4ae..0a9e417 100644 (file)
@@ -128,6 +128,12 @@ public:
   ////////////////////////////////////////
 
   /**
+   * @brief Clear all caches in FontClient
+   *
+   */
+  void ClearCache();
+
+  /**
    * @brief Set the DPI of the target window.
    *
    * @note Multiple windows are not currently supported.
index 497c8f4..fe4f661 100644 (file)
@@ -73,6 +73,15 @@ Dali::TextAbstraction::FontClient FontClient::Get()
   return fontClientHandle;
 }
 
+void FontClient::ClearCache()
+{
+  if( mPlugin )
+  {
+    mPlugin->ClearCache();
+  }
+}
+
+
 void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi  )
 {
   mDpiHorizontal = horizontalDpi;
index 13d847b..725f0e0 100644 (file)
@@ -56,6 +56,11 @@ public:
   static Dali::TextAbstraction::FontClient Get();
 
   /**
+   * @copydoc Dali::TextAbstraction::FontClient::ClearCache()
+   */
+  void ClearCache();
+
+  /**
    * @copydoc Dali::TextAbstraction::FontClient::SetDpi()
    */
   void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
index 5edf88d..5020d28 100644 (file)
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/devel-api/text-abstraction/font-list.h>
+
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/integration-api/debug.h>
@@ -91,6 +92,8 @@ const unsigned int NUM_FONT_SLANT_TYPE = sizeof( FONT_SLANT_TYPE_TO_INT ) / size
 
 } // namespace
 
+
+
 using Dali::Vector;
 
 namespace Dali
@@ -230,6 +233,7 @@ FontClient::Plugin::Plugin( unsigned int horizontalDpi,
 #ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
   mVectorFontCache = new VectorFontCache( mFreeTypeLibrary );
 #endif
+
 }
 
 FontClient::Plugin::~Plugin()
@@ -256,6 +260,35 @@ FontClient::Plugin::~Plugin()
   FT_Done_FreeType( mFreeTypeLibrary );
 }
 
+void FontClient::Plugin::ClearCache()
+{
+  mFontCache.clear();
+  mValidatedFontCache.clear();
+  mFontDescriptionCache.clear();
+  mFontDescriptionCache.resize( 1u );
+
+  mCharacterSetCache.Clear();
+  mCharacterSetCache.Resize( 1u );
+
+  mFontIdCache.clear();
+  mFallbackCache.clear();
+
+#ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
+  if(mVectorFontCache)
+  {
+    mVectorFontCache.clear();
+    mVectorFontCache = NULL;
+  }
+#endif
+
+  mEllipsisCache.Clear();
+  mSystemFonts.clear();
+  mDefaultFonts.clear();
+  mDefaultFontDescriptionCached = false;
+  mDefaultFontCharacterSets.Clear();
+  mDefaultFontDescription = FontDescription();
+}
+
 void FontClient::Plugin::SetDpi( unsigned int horizontalDpi,
                                  unsigned int verticalDpi )
 {
index a1ceb9a..5cc45d3 100644 (file)
@@ -157,6 +157,11 @@ struct FontClient::Plugin
   ~Plugin();
 
   /**
+   * @copydoc Dali::TextAbstraction::FontClient::ClearCache()
+   */
+  void ClearCache();
+
+  /**
    * @copydoc Dali::TextAbstraction::FontClient::SetDpi()
    */
   void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
index 24c542c..4d389c5 100644 (file)
@@ -200,7 +200,7 @@ struct Shaping::Plugin
 
     std::istringstream stringStream( currentLocale );
     std::string localeString;
-    std::getline(stringStream, localeString, '_');
+    std::getline(stringStream, localeString, '.');
     hb_buffer_set_language( harfBuzzBuffer, hb_language_from_string( localeString.c_str(), localeString.size() ) );
 
     /* Layout the text */
@@ -213,6 +213,7 @@ struct Shaping::Plugin
     hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( harfBuzzBuffer, &glyphCount );
     hb_glyph_position_t *glyphPositions = hb_buffer_get_glyph_positions( harfBuzzBuffer, &glyphCount );
     const GlyphIndex lastGlyphIndex = glyphCount - 1u;
+
     for( GlyphIndex i = 0u; i < glyphCount; )
     {
       if( rtlDirection )