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 FindValidFont( 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] size The given size.
99 * @return The font id of a default font for the given @p size. If there isn't any font cached it returns 0.
101 FontId FindFont( TextAbstraction::FontClient& fontClient, PointSize26Dot6 size ) const;
103 Vector<FontId> mFonts;
107 * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
109 class MultilanguageSupport : public BaseObject
116 MultilanguageSupport();
121 * This is non-virtual since derived Handle types must not contain data or virtual methods.
123 ~MultilanguageSupport();
126 * @copydoc Dali::MultilanguageSupport::Get()
128 static Text::MultilanguageSupport Get();
131 * @copydoc Dali::MultilanguageSupport::SetScripts()
133 void SetScripts( const Vector<Character>& text,
134 CharacterIndex startIndex,
135 Length numberOfCharacters,
136 Vector<ScriptRun>& scripts );
139 * @copydoc Dali::MultilanguageSupport::ValidateFonts()
141 void ValidateFonts( const Vector<Character>& text,
142 const Vector<ScriptRun>& scripts,
143 const Vector<FontDescriptionRun>& fontDescriptions,
144 FontId defaultFontId,
145 CharacterIndex startIndex,
146 Length numberOfCharacters,
147 Vector<FontRun>& fonts );
150 Vector<DefaultFonts*> mDefaultFontPerScriptCache; ///< Caches default fonts for a script.
151 Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache; ///< Caches valid fonts for a script.
154 } // namespace Internal
156 inline static Internal::MultilanguageSupport& GetImplementation( MultilanguageSupport& multilanguageSupport )
158 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
159 BaseObject& handle = multilanguageSupport.GetBaseObject();
160 return static_cast<Internal::MultilanguageSupport&>( handle );
163 inline static const Internal::MultilanguageSupport& GetImplementation( const MultilanguageSupport& multilanguageSupport )
165 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
166 const BaseObject& handle = multilanguageSupport.GetBaseObject();
167 return static_cast<const Internal::MultilanguageSupport&>( handle );
172 } // namespace Toolkit
176 #endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__