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.
81 * Default constructor.
94 * @brief Finds a default font for the given @p size.
96 * @param[in] fontClient The font client.
97 * @param[in] description The font's description.
98 * @param[in] size The given size.
100 * @return The font id of a default font for the given @p size. If there isn't any font cached it returns 0.
102 FontId FindFont( TextAbstraction::FontClient& fontClient,
103 const TextAbstraction::FontDescription& description,
104 PointSize26Dot6 size ) const;
106 Vector<FontId> mFonts;
110 * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
112 class MultilanguageSupport : public BaseObject
119 MultilanguageSupport();
124 * This is non-virtual since derived Handle types must not contain data or virtual methods.
126 ~MultilanguageSupport();
129 * @copydoc Dali::MultilanguageSupport::Get()
131 static Text::MultilanguageSupport Get();
134 * @copydoc Dali::MultilanguageSupport::SetScripts()
136 void SetScripts( const Vector<Character>& text,
137 CharacterIndex startIndex,
138 Length numberOfCharacters,
139 Vector<ScriptRun>& scripts );
142 * @copydoc Dali::MultilanguageSupport::ValidateFonts()
144 void ValidateFonts( const Vector<Character>& text,
145 const Vector<ScriptRun>& scripts,
146 const Vector<FontDescriptionRun>& fontDescriptions,
147 const TextAbstraction::FontDescription& defaultFontDescription,
148 TextAbstraction::PointSize26Dot6 defaultFontPointSize,
149 CharacterIndex startIndex,
150 Length numberOfCharacters,
151 Vector<FontRun>& fonts );
154 Vector<DefaultFonts*> mDefaultFontPerScriptCache; ///< Caches default fonts for a script.
155 Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache; ///< Caches valid fonts for a script.
158 } // namespace Internal
160 inline static Internal::MultilanguageSupport& GetImplementation( MultilanguageSupport& multilanguageSupport )
162 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
163 BaseObject& handle = multilanguageSupport.GetBaseObject();
164 return static_cast<Internal::MultilanguageSupport&>( handle );
167 inline static const Internal::MultilanguageSupport& GetImplementation( const MultilanguageSupport& multilanguageSupport )
169 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
170 const BaseObject& handle = multilanguageSupport.GetBaseObject();
171 return static_cast<const Internal::MultilanguageSupport&>( handle );
176 } // namespace Toolkit
180 #endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__