1 #ifndef __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__
2 #define __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-object.h>
25 #include <dali-toolkit/internal/text/multi-language-support.h>
30 namespace TextAbstraction
46 * @brief Stores valid font ids per script.
48 struct ValidateFontsPerScript
51 * Default constructor.
53 ValidateFontsPerScript()
60 ~ValidateFontsPerScript()
64 * @brief Whether the given @p fontId is in the vector of valid fonts.
66 * @param[in] fontId The font id.
68 * @return @e true if the font is in the vector of valid fonts.
70 bool IsValidFont( FontId fontId ) const;
72 Vector<FontId> mValidFonts;
76 * @brief Stores default font ids per script. It can be different sizes for a default font family.
82 TextAbstraction::FontDescription description;
87 * Default constructor.
100 * @brief Finds a default font for the given @p size.
102 * @param[in] fontClient The font client.
103 * @param[in] description The font's description.
104 * @param[in] size The given size.
106 * @return The font id of a default font for the given @p size. If there isn't any font cached it returns 0.
108 FontId FindFont( TextAbstraction::FontClient& fontClient,
109 const TextAbstraction::FontDescription& description,
110 PointSize26Dot6 size ) const;
112 void Cache( const TextAbstraction::FontDescription& description, FontId fontId );
114 std::vector<CacheItem> mFonts;
118 * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
120 class MultilanguageSupport : public BaseObject
127 MultilanguageSupport();
132 * This is non-virtual since derived Handle types must not contain data or virtual methods.
134 ~MultilanguageSupport();
137 * @copydoc Dali::MultilanguageSupport::Get()
139 static Text::MultilanguageSupport Get();
142 * @copydoc Dali::MultilanguageSupport::SetScripts()
144 void SetScripts( const Vector<Character>& text,
145 CharacterIndex startIndex,
146 Length numberOfCharacters,
147 Vector<ScriptRun>& scripts );
150 * @copydoc Dali::MultilanguageSupport::ValidateFonts()
152 void ValidateFonts( const Vector<Character>& text,
153 const Vector<ScriptRun>& scripts,
154 const Vector<FontDescriptionRun>& fontDescriptions,
155 const TextAbstraction::FontDescription& defaultFontDescription,
156 TextAbstraction::PointSize26Dot6 defaultFontPointSize,
157 CharacterIndex startIndex,
158 Length numberOfCharacters,
159 Vector<FontRun>& fonts );
162 Vector<DefaultFonts*> mDefaultFontPerScriptCache; ///< Caches default fonts for a script.
163 Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache; ///< Caches valid fonts for a script.
166 } // namespace Internal
168 inline static Internal::MultilanguageSupport& GetImplementation( MultilanguageSupport& multilanguageSupport )
170 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
171 BaseObject& handle = multilanguageSupport.GetBaseObject();
172 return static_cast<Internal::MultilanguageSupport&>( handle );
175 inline static const Internal::MultilanguageSupport& GetImplementation( const MultilanguageSupport& multilanguageSupport )
177 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
178 const BaseObject& handle = multilanguageSupport.GetBaseObject();
179 return static_cast<const Internal::MultilanguageSupport&>( handle );
184 } // namespace Toolkit
188 #endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__