[Tizen] Add LocaleChangedSignal 18/303618/1
authorANZ1217 <chihun.jeong@samsung.com>
Fri, 22 Dec 2023 05:38:29 +0000 (14:38 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 2 Jan 2024 11:32:07 +0000 (20:32 +0900)
LocaleChangedSignal is a signal that works when the system locale is changed.
To solve the problem that the default font does not change when changing the system language, clear the cache of fontClient and emit LocaleChangedSignal.

Change-Id: Ic543b9fc250ccf88cd460fe08da6b5fd2c008987

12 files changed:
dali/devel-api/text-abstraction/font-client.cpp
dali/devel-api/text-abstraction/font-client.h
dali/integration-api/adaptor-framework/adaptor.h
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/adaptor/common/adaptor.cpp
dali/internal/adaptor/tizen-wayland/adaptor-impl-tizen.cpp
dali/internal/text/text-abstraction/font-client-impl.cpp
dali/internal/text/text-abstraction/font-client-impl.h
dali/internal/text/text-abstraction/plugin/font-client-plugin-cache-handler.cpp
dali/internal/text/text-abstraction/plugin/font-client-plugin-cache-handler.h
dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp
dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.h

index 116c00af13015d806093bd491548d5cd53ffccb2..10e23d3f4de2a0237636c3e07228a2ba37e0898c 100644 (file)
@@ -112,6 +112,11 @@ void FontClient::ClearCache()
   GetImplementation(*this).ClearCache();
 }
 
+void FontClient::ClearCacheOnLocaleChanged()
+{
+  GetImplementation(*this).ClearCacheOnLocaleChanged();
+}
+
 void FontClient::SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi)
 {
   GetImplementation(*this).SetDpi(horizontalDpi, verticalDpi);
index bce3e4e846c6fae6e6324e0eeb9907a4d3c2e7fe..61647ec1b7b3268645f15a899cb9bf8bbd1324bd 100644 (file)
@@ -163,6 +163,13 @@ public:
    */
   void ClearCache();
 
+  /**
+   * @brief Clear caches in FontClient when Locale Changed
+   *
+   * @note This function only clears caches that needs to be cleared.
+   */
+  void ClearCacheOnLocaleChanged();
+
   /**
    * @brief Set the DPI of the target window.
    *
index 0d80b351df010600738355b3f9c61dc0abd5d63f..07e78a699e1ae350e84d97a8a90e8dd769cacb27 100644 (file)
@@ -119,6 +119,7 @@ class DALI_ADAPTOR_API Adaptor
 public:
   typedef Signal<void(Adaptor&)>                        AdaptorSignalType;       ///< Generic Type for adaptor signals
   typedef Signal<void(Dali::Integration::SceneHolder&)> WindowCreatedSignalType; ///< SceneHolder created signal type
+  typedef Signal<void(std::string)>                     LocaleChangedSignalType; ///< Locale changed signal type
 
   using SurfaceSize = Uint16Pair; ///< Surface size type
 
@@ -486,6 +487,13 @@ public: // Signals
    */
   WindowCreatedSignalType& WindowCreatedSignal();
 
+  /**
+   * @brief This signal is emitted when the system locale is changed
+   *
+   * @return The signal to connect to
+   */
+  LocaleChangedSignalType& LocaleChangedSignal();
+
 private:
   // Undefined
   Adaptor(const Adaptor&);
index 20b93a81a78bf66b43251aa662f2831c99fcb540..aaff35078f4e51e31576aa075d78a704a06daaee 100644 (file)
@@ -96,6 +96,7 @@ class Adaptor : public Integration::RenderController,
 public:
   using AdaptorSignalType       = Dali::Adaptor::AdaptorSignalType;
   using WindowCreatedSignalType = Dali::Adaptor::WindowCreatedSignalType;
+  using LocaleChangedSignalType = Dali::Adaptor::LocaleChangedSignalType;
 
   using SurfaceSize = Uint16Pair; ///< Surface size type
 
@@ -566,6 +567,14 @@ public: // Signals
     return mWindowCreatedSignal;
   }
 
+  /**
+   * @copydoc Dali::Adaptor::LocaleChangedSignal
+   */
+  LocaleChangedSignalType& LocaleChangedSignal()
+  {
+    return mLocaleChangedSignal;
+  }
+
 public: // From Dali::Internal::Adaptor::CoreEventInterface
   /**
    * @copydoc Dali::Internal::Adaptor::CoreEventInterface:::FlushUpdateMessages()
@@ -703,6 +712,7 @@ private:                                          // Data
   AdaptorSignalType       mResizedSignal;         ///< Resized signal.
   AdaptorSignalType       mLanguageChangedSignal; ///< Language changed signal.
   WindowCreatedSignalType mWindowCreatedSignal;   ///< Window created signal.
+  LocaleChangedSignalType mLocaleChangedSignal;   ///< Locale changed signal.
 
   Dali::Adaptor&           mAdaptor;          ///< Reference to public adaptor instance.
   State                    mState;            ///< Current state of the adaptor
index c8d17eee7412cdd1d64494409f2725783638c597..9c347b43bfdf5ba2e0d43b001358d6cc9345605c 100644 (file)
@@ -135,6 +135,11 @@ Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
   return mImpl->WindowCreatedSignal();
 }
 
+Adaptor::LocaleChangedSignalType& Adaptor::LocaleChangedSignal()
+{
+  return mImpl->LocaleChangedSignal();
+}
+
 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
 {
   return mImpl->GetSurface();
index 3442ca128e9d10c1d243ff998ca773e8e9ae6ca1..1e415a9e677a0c8eb5acdb1c3909d2610a126550 100644 (file)
@@ -35,6 +35,9 @@
 #include <aul.h>
 #include <unistd.h>
 
+// INTERNAL INCLUDES
+#include <dali/devel-api/text-abstraction/font-client.h>
+
 namespace Dali
 {
 namespace Internal
@@ -56,7 +59,12 @@ static void OnSystemLanguageChanged(system_settings_key_e key, void* data)
   Adaptor* adaptor = static_cast<Adaptor*>(data);
   if(adaptor != NULL)
   {
+    TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+    fontClient.ClearCacheOnLocaleChanged();
+    fontClient.InitDefaultFontDescription();
+
     adaptor->SetRootLayoutDirection(locale);
+    adaptor->LocaleChangedSignal().Emit(locale);
   }
 
   free(locale);
index 3b960a7dc1c24b68fd5b9154ef167a06bbafa574..031c78a81678fa037c2cfaf20b4691d926b7e22a 100644 (file)
@@ -335,6 +335,14 @@ void FontClient::ClearCache()
   }
 }
 
+void FontClient::ClearCacheOnLocaleChanged()
+{
+  if(mPlugin)
+  {
+    mPlugin->ClearCacheOnLocaleChanged();
+  }
+}
+
 void FontClient::SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi)
 {
   mDpiHorizontal = horizontalDpi;
index ca7fe5e6a8b07cad1e718aa602a4de16f6a3171e..ff86fd960e1087b811a38a3b92f2987357f73bec 100644 (file)
@@ -97,6 +97,11 @@ public: // API for Dali::TextAbstraction::FontClient used.
    */
   void ClearCache();
 
+  /**
+   * @copydoc Dali::TextAbstraction::FontClient::ClearCacheOnLocaleChanged()
+   */
+  void ClearCacheOnLocaleChanged();
+
   /**
    * @copydoc Dali::TextAbstraction::FontClient::SetDpi()
    */
index 2509c8d6a5349c01d11e055db72f0e5b45ee8834..d1d24a1dfc5d1f8fb58177ec00d0c3b31ee2122f 100644 (file)
@@ -358,6 +358,47 @@ void FontClient::Plugin::CacheHandler::ClearCache()
   mDefaultFontDescriptionCached = false;
 }
 
+void FontClient::Plugin::CacheHandler::ClearCacheOnLocaleChanged()
+{
+  // delete cached glyph informations before clear mFontFaceCache.
+  mGlyphCacheManager->ClearCache();
+
+  mDefaultFontDescription = FontDescription();
+
+  mSystemFonts.clear();
+  mDefaultFonts.clear();
+
+  DestroyCharacterSets(mDefaultFontCharacterSets);
+  mDefaultFontCharacterSets.Clear();
+
+  ClearFallbackCache();
+  mFallbackCache.clear();
+
+  mFontIdCache.clear();
+
+  ClearCharacterSetFromFontFaceCache();
+  mFontFaceCache.clear();
+
+  mValidatedFontCache.clear();
+  mFontDescriptionCache.clear();
+
+  DestroyCharacterSets(mCharacterSetCache);
+  mCharacterSetCache.Clear();
+
+  mFontDescriptionSizeCache.clear();
+  mFontDescriptionSizeCache.rehash(0); // Note : unordered_map.clear() didn't deallocate memory
+
+  mEllipsisCache.clear();
+  mPixelBufferCache.clear();
+  mEmbeddedItemCache.clear();
+  mBitmapFontCache.clear();
+
+  mLatestFoundFontDescription.family.clear();
+  mLatestFoundCacheKey = FontDescriptionSizeCacheKey(0, 0);
+
+  mDefaultFontDescriptionCached = false;
+}
+
 void FontClient::Plugin::CacheHandler::ResetSystemDefaults()
 {
   mDefaultFontDescriptionCached = false;
index d61fb72ca45f75a4f27e101550302e9efefe4b92..5f4f0fd1e2deef1b5bb32a0613e08f26beb3a157 100644 (file)
@@ -131,6 +131,11 @@ public: // Clear cache public
    */
   void ClearCache();
 
+  /**
+   * @copydoc Dali::TextAbstraction::FontClient::Plugin::ClearCacheOnLocaleChanged()
+   */
+  void ClearCacheOnLocaleChanged();
+
   /**
    * @copydoc Dali::TextAbstraction::FontClient::Plugin::ResetSystemDefaults()
    */
index d31df24bc80e9123d2c9583075aadb747d3d3e38..99caffed6093a92bf921821f049afcf06a8c4309 100644 (file)
@@ -269,6 +269,11 @@ void FontClient::Plugin::ClearCache() const
   mCacheHandler->ClearCache();
 }
 
+void FontClient::Plugin::ClearCacheOnLocaleChanged() const
+{
+  mCacheHandler->ClearCacheOnLocaleChanged();
+}
+
 void FontClient::Plugin::SetDpi(unsigned int horizontalDpi,
                                 unsigned int verticalDpi)
 {
index 172b2471aff7f0cee4cb54402619279484bcf050..ef4738738fc6060173081a72ad901ec30c840d2e 100644 (file)
@@ -94,6 +94,11 @@ public: // Dali::TextAbstraction::FontClient
    */
   void ClearCache() const;
 
+  /**
+   * @copydoc Dali::TextAbstraction::FontClient::ClearCacheOnLocaleChanged()
+   */
+  void ClearCacheOnLocaleChanged() const;
+
   /**
    * @copydoc Dali::TextAbstraction::FontClient::SetDpi()
    */