[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / multi-language-support-impl.h
index cda767a..2f0a904 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/base-object.h>
+#include <dali/public-api/signals/connection-tracker.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/multi-language-support.h>
@@ -67,6 +68,14 @@ struct ValidateFontsPerScript
    */
   bool IsValidFont(FontId fontId) const;
 
+  /**
+   * @brief Cache the given @p fontId in the vector of valid fonts.
+   * @note If cache size is big enough, we might remove some caches.
+   *
+   * @param[in] fontId The font id.
+   */
+  void Cache(FontId fontId);
+
   Vector<FontId> mValidFonts;
 };
 
@@ -109,6 +118,13 @@ struct DefaultFonts
                   const TextAbstraction::FontDescription& description,
                   PointSize26Dot6                         size) const;
 
+  /**
+   * @brief Cache a default font for the given @p size.
+   * @note If cache size is big enough, we might remove some caches.
+   *
+   * @param[in] description The font's description.
+   * @param[in] fontId The font id.
+   */
   void Cache(const TextAbstraction::FontDescription& description, FontId fontId);
 
   std::vector<CacheItem> mFonts;
@@ -117,7 +133,7 @@ struct DefaultFonts
 /**
  * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
  */
-class MultilanguageSupport : public BaseObject
+class MultilanguageSupport : public BaseObject, public ConnectionTracker
 {
 public:
   /**
@@ -153,14 +169,33 @@ public:
                      const Vector<FontDescriptionRun>&       fontDescriptions,
                      const TextAbstraction::FontDescription& defaultFontDescription,
                      TextAbstraction::PointSize26Dot6        defaultFontPointSize,
+                     float                                   fontSizeScale,
                      CharacterIndex                          startIndex,
                      Length                                  numberOfCharacters,
                      Vector<FontRun>&                        fonts);
 
+  /**
+   * @brief Callback function for when the locale is changed.
+   * @param[in] locale The new system locale.
+   */
+  void OnLocaleChanged(std::string locale);
+
+  /**
+   * @brief Clear font caches when locale changed.
+   */
+  void ClearCache();
+
+  /**
+   * @brief Gets the locale.
+   */
+  std::string GetLocale();
+
 private:
   Vector<DefaultFonts*>           mDefaultFontPerScriptCache; ///< Caches default fonts for a script.
   Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache;  ///< Caches valid fonts for a script.
 
+  std::string mLocale;
+
   //Methods
 
   /**