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>
26 #include <dali/integration-api/adaptors/adaptor.h>
31 namespace TextAbstraction
47 * @brief Stores valid font ids per script.
49 struct ValidateFontsPerScript
52 * Default constructor.
54 ValidateFontsPerScript()
61 ~ValidateFontsPerScript()
65 * @brief Whether the given @p fontId is in the vector of valid fonts.
67 * @param[in] fontId The font id.
69 * @return @e true if the font is in the vector of valid fonts.
71 bool IsValidFont( FontId fontId ) const;
73 Vector<FontId> mValidFonts;
77 * @brief Stores default font ids per script. It can be different sizes for a default font family.
83 TextAbstraction::FontDescription description;
88 * Default constructor.
101 * @brief Finds a default font for the given @p size.
103 * @param[in] fontClient The font client.
104 * @param[in] description The font's description.
105 * @param[in] size The given size.
107 * @return The font id of a default font for the given @p size. If there isn't any font cached it returns 0.
109 FontId FindFont( TextAbstraction::FontClient& fontClient,
110 const TextAbstraction::FontDescription& description,
111 PointSize26Dot6 size ) const;
113 void Cache( const TextAbstraction::FontDescription& description, FontId fontId );
115 std::vector<CacheItem> mFonts;
119 * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
121 class MultilanguageSupport : public BaseObject
128 MultilanguageSupport();
133 * This is non-virtual since derived Handle types must not contain data or virtual methods.
135 ~MultilanguageSupport();
139 * Dali::MultilanguageSupport::OnLanguageChanged()
141 * Get notice when system language is changed.
143 void OnLanguageChanged( Dali::Adaptor& adaptor );
146 * @copydoc Dali::MultilanguageSupport::Get()
148 static Text::MultilanguageSupport Get();
151 * @copydoc Dali::MultilanguageSupport::SetScripts()
153 void SetScripts( const Vector<Character>& text,
154 CharacterIndex startIndex,
155 Length numberOfCharacters,
156 Vector<ScriptRun>& scripts );
159 * @copydoc Dali::MultilanguageSupport::ValidateFonts()
161 void ValidateFonts( const Vector<Character>& text,
162 const Vector<ScriptRun>& scripts,
163 const Vector<FontDescriptionRun>& fontDescriptions,
164 const TextAbstraction::FontDescription& defaultFontDescription,
165 TextAbstraction::PointSize26Dot6 defaultFontPointSize,
166 CharacterIndex startIndex,
167 Length numberOfCharacters,
168 Vector<FontRun>& fonts );
171 Vector<DefaultFonts*> mDefaultFontPerScriptCache; ///< Caches default fonts for a script.
172 Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache; ///< Caches valid fonts for a script.
173 SlotDelegate< MultilanguageSupport > mSlotDelegate; //< SlotDelegate to listen LanguageChangedSignal.
176 } // namespace Internal
178 inline static Internal::MultilanguageSupport& GetImplementation( MultilanguageSupport& multilanguageSupport )
180 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
181 BaseObject& handle = multilanguageSupport.GetBaseObject();
182 return static_cast<Internal::MultilanguageSupport&>( handle );
185 inline static const Internal::MultilanguageSupport& GetImplementation( const MultilanguageSupport& multilanguageSupport )
187 DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
188 const BaseObject& handle = multilanguageSupport.GetBaseObject();
189 return static_cast<const Internal::MultilanguageSupport&>( handle );
194 } // namespace Toolkit
198 #endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__