Fix for multi-language support.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / multi-language-support-impl.h
index 65933b5..c9a7d30 100644 (file)
  *
  */
 
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/text/multi-language-support.h>
-
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/base-object.h>
 
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/multi-language-support.h>
+
 namespace Dali
 {
 
+namespace TextAbstraction
+{
+//Forward declaration
+class FontClient;
+}
+
 namespace Toolkit
 {
 
@@ -61,12 +67,54 @@ struct ValidateFontsPerScript
    *
    * @return @e true if the font is in the vector of valid fonts.
    */
-  bool FindValidFont( FontId fontId ) const;
+  bool IsValidFont( FontId fontId ) const;
 
   Vector<FontId> mValidFonts;
 };
 
 /**
+ * @brief Stores default font ids per script. It can be different sizes for a default font family.
+ */
+struct DefaultFonts
+{
+  struct CacheItem
+  {
+    TextAbstraction::FontDescription description;
+    FontId fontId;
+  };
+
+  /**
+   * Default constructor.
+   */
+  DefaultFonts()
+  : mFonts()
+  {}
+
+  /**
+   * Default destructor.
+   */
+  ~DefaultFonts()
+  {}
+
+  /**
+   * @brief Finds a default font for the given @p size.
+   *
+   * @param[in] fontClient The font client.
+   * @param[in] description The font's description.
+   * @param[in] size The given size.
+   *
+   * @return The font id of a default font for the given @p size. If there isn't any font cached it returns 0.
+   */
+  FontId FindFont( TextAbstraction::FontClient& fontClient,
+                   const TextAbstraction::FontDescription& description,
+                   PointSize26Dot6 size ) const;
+
+  void Cache( const TextAbstraction::FontDescription& description, FontId fontId );
+
+  std::vector<CacheItem> mFonts;
+};
+
+/**
  * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
  */
 class MultilanguageSupport : public BaseObject
@@ -94,33 +142,24 @@ public:
    * @copydoc Dali::MultilanguageSupport::SetScripts()
    */
   void SetScripts( const Vector<Character>& text,
-                   const Vector<LineBreakInfo>& lineBreakInfo,
+                   CharacterIndex startIndex,
+                   Length numberOfCharacters,
                    Vector<ScriptRun>& scripts );
 
   /**
-   * @copydoc Dali::MultilanguageSupport::ReplaceScripts()
-   */
-  void ReplaceScripts( LogicalModel& model,
-                       CharacterIndex characterIndex,
-                       Length numberOfCharactersToRemove,
-                       Length numberOfCharactersToInsert );
-
-  /**
-   * @copydoc Dali::MultilanguageSupport::ValidateFonts( const Vector<Character>& text, const Vector<ScriptRun>& scripts, Vector<FontRun>& fonts )
+   * @copydoc Dali::MultilanguageSupport::ValidateFonts()
    */
   void ValidateFonts( const Vector<Character>& text,
                       const Vector<ScriptRun>& scripts,
+                      const Vector<FontDescriptionRun>& fontDescriptions,
+                      const TextAbstraction::FontDescription& defaultFontDescription,
+                      TextAbstraction::PointSize26Dot6 defaultFontPointSize,
+                      CharacterIndex startIndex,
+                      Length numberOfCharacters,
                       Vector<FontRun>& fonts );
 
-  /**
-   * @copydoc Dali::MultilanguageSupport::ValidateFonts( LogicalModel& model, CharacterIndex characterIndex, Length numberOfCharactersToRemove, Length numberOfCharactersToInsert )
-   */
-  void ValidateFonts( LogicalModel& model,
-                      CharacterIndex characterIndex,
-                      Length numberOfCharactersToRemove,
-                      Length numberOfCharactersToInsert );
 private:
-  Vector<FontId>                  mDefaultFontPerScriptCache; ///< Caches the default font for a script.
+  Vector<DefaultFonts*>           mDefaultFontPerScriptCache; ///< Caches default fonts for a script.
   Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache;  ///< Caches valid fonts for a script.
 };