X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fmulti-language-support-impl.h;h=cda767a99c3d184d865a4f1e47e8023baa725799;hp=0f7e1770cdaa3964f67c35a3ca48b4d7b6995c5f;hb=fbd8d4da2506b57b46a71c5d113f4cb86f23c731;hpb=3bdbf66c314bb6036eb35ec0d2f1c9c32652f931 diff --git a/dali-toolkit/internal/text/multi-language-support-impl.h b/dali-toolkit/internal/text/multi-language-support-impl.h index 0f7e177..cda767a 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.h +++ b/dali-toolkit/internal/text/multi-language-support-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__ -#define __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__ +#ifndef DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H +#define DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -26,16 +26,18 @@ namespace Dali { +namespace TextAbstraction +{ +//Forward declaration +class FontClient; +} // namespace TextAbstraction namespace Toolkit { - namespace Text { - namespace Internal { - /** * @brief Stores valid font ids per script. */ @@ -46,13 +48,15 @@ struct ValidateFontsPerScript */ ValidateFontsPerScript() : mValidFonts() - {} + { + } /** * Default destructor. */ ~ValidateFontsPerScript() - {} + { + } /** * @brief Whether the given @p fontId is in the vector of valid fonts. @@ -61,18 +65,61 @@ 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 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 mFonts; +}; + +/** * @brief Multi-language support implementation. @see Text::MultilanguageSupport. */ class MultilanguageSupport : public BaseObject { public: - /** * Constructor */ @@ -93,51 +140,64 @@ public: /** * @copydoc Dali::MultilanguageSupport::SetScripts() */ - void SetScripts( const Vector& text, - const Vector& lineBreakInfo, - Vector& scripts ); - - /** - * @copydoc Dali::MultilanguageSupport::ReplaceScripts() - */ - void ReplaceScripts( LogicalModel& model, - CharacterIndex characterIndex, - Length numberOfCharactersToRemove, - Length numberOfCharactersToInsert ); + void SetScripts(const Vector& text, + CharacterIndex startIndex, + Length numberOfCharacters, + Vector& scripts); /** - * @copydoc Dali::MultilanguageSupport::ValidateFonts( const Vector& text, const Vector& scripts, Vector& fonts ) + * @copydoc Dali::MultilanguageSupport::ValidateFonts() */ - void ValidateFonts( const Vector& text, - const Vector& scripts, - Vector& fonts ); + void ValidateFonts(const Vector& text, + const Vector& scripts, + const Vector& fontDescriptions, + const TextAbstraction::FontDescription& defaultFontDescription, + TextAbstraction::PointSize26Dot6 defaultFontPointSize, + CharacterIndex startIndex, + Length numberOfCharacters, + Vector& 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 mDefaultFontPerScriptCache; ///< Caches the default font for a script. + Vector mDefaultFontPerScriptCache; ///< Caches default fonts for a script. Vector mValidFontsPerScriptCache; ///< Caches valid fonts for a script. + + //Methods + + /** + * @brief Add the current script to scripts and create new script. + * + * @param[in] requestedScript The script of the new script run. + * @param[in] isRightToLeft The direction of the new script run. + * @param[in] addScriptCharactersToNewScript Whether to add the pending characters to the new script run or to the current script run. + * @param[inout] currentScriptRun The current character script run and it will be updated it to the new script run. + * @param[inout] numberOfAllScriptCharacters The pending characters. + * @param[inout] scripts The list of scripts. + * @param[inout] scriptIndex The current index of scripts. + * + */ + void AddCurrentScriptAndCreatNewScript(const Script requestedScript, + const bool isRightToLeft, + const bool addScriptCharactersToNewScript, + ScriptRun& currentScriptRun, + Length& numberOfAllScriptCharacters, + Vector& scripts, + ScriptRunIndex& scriptIndex); }; } // namespace Internal -inline static Internal::MultilanguageSupport& GetImplementation( MultilanguageSupport& multilanguageSupport ) +inline static Internal::MultilanguageSupport& GetImplementation(MultilanguageSupport& multilanguageSupport) { - DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" ); + DALI_ASSERT_ALWAYS(multilanguageSupport && "multi-language handle is empty"); BaseObject& handle = multilanguageSupport.GetBaseObject(); - return static_cast( handle ); + return static_cast(handle); } -inline static const Internal::MultilanguageSupport& GetImplementation( const MultilanguageSupport& multilanguageSupport ) +inline static const Internal::MultilanguageSupport& GetImplementation(const MultilanguageSupport& multilanguageSupport) { - DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" ); + DALI_ASSERT_ALWAYS(multilanguageSupport && "multi-language handle is empty"); const BaseObject& handle = multilanguageSupport.GetBaseObject(); - return static_cast( handle ); + return static_cast(handle); } } // namespace Text @@ -146,4 +206,4 @@ inline static const Internal::MultilanguageSupport& GetImplementation( const Mul } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__ +#endif // DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H