1 #ifndef DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H
2 #define DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H
5 * Copyright (c) 2021 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/common/dali-vector.h>
23 #include <dali/public-api/object/base-handle.h>
26 #include <dali-toolkit/internal/text/font-description-run.h>
27 #include <dali-toolkit/internal/text/font-run.h>
28 #include <dali-toolkit/internal/text/script-run.h>
36 namespace Internal DALI_INTERNAL
38 class MultilanguageSupport;
40 } // namespace DALI_INTERNAL
43 * @brief Sets the character's scripts to the model and validates the fonts set by the user or assigns default ones.
45 class MultilanguageSupport : public BaseHandle
49 * @brief Create an uninitialized MultilanguageSupport handle.
51 MultilanguageSupport();
56 * This is non-virtual since derived Handle types must not contain data or virtual methods.
58 ~MultilanguageSupport();
61 * @brief This constructor is used by MultilanguageSupport::Get().
63 * @param[in] implementation A pointer to the internal multi-language support object.
65 explicit DALI_INTERNAL MultilanguageSupport(Internal::MultilanguageSupport* implementation);
68 * @brief Retrieve a handle to the MultilanguageSupport instance.
70 * @return A handle to the MultilanguageSupport.
72 static MultilanguageSupport Get();
75 * @brief Sets the scripts of the whole text.
77 * Scripts are used to validate and set default fonts and to shape the text in further steps.
79 * Some characters (like white spaces) are valid for many scripts. The rules to set a script
81 * - If they are at the begining of a paragraph they get the script of the first character with
82 * a defined script. If they are at the end, they get the script of the last one.
83 * - If they are between two scripts with the same direction, they get the script of the previous
84 * character with a defined script. If the two scripts have different directions, they get the
85 * script of the first character of the paragraph with a defined script.
87 * @param[in] text Vector of UTF-32 characters.
88 * @param[in] startIndex The character from where the script info is set.
89 * @param[in] numberOfCharacters The number of characters to set the script.
90 * @param[out] scripts Vector containing the script runs for the whole text.
92 void SetScripts(const Vector<Character>& text,
93 CharacterIndex startIndex,
94 Length numberOfCharacters,
95 Vector<ScriptRun>& scripts);
98 * @brief Validates the character's font of the whole text.
100 * This method ensures all characters are going to be rendered using an appropriate font. Provided a valid font
101 * exists in the platform.
103 * For those characters with no font set, it sets a default one.
105 * If a font has been set by the application developer, this method checks if the font supports the character.
106 * If it doesn't, this method replaces it by a default one.
108 * @param[in] text Vector of UTF-32 characters.
109 * @param[in] scripts Vector containing the script runs for the whole text.
110 * @param[in] fontDescriptions The fonts set through the mark-up string or the input style set through the property system.
111 * @param[in] defaultFontDescription The default font's description set through the property system.
112 * @param[in] defaultFontPointSize The default font's point size set through the property system.
113 * @param[in] startIndex The character from where the font info is set.
114 * @param[in] numberOfCharacters The number of characters to set the font.
115 * @param[out] fonts The validated fonts.
117 void ValidateFonts(const Vector<Character>& text,
118 const Vector<ScriptRun>& scripts,
119 const Vector<FontDescriptionRun>& fontDescriptions,
120 const TextAbstraction::FontDescription& defaultFontDescription,
121 TextAbstraction::PointSize26Dot6 defaultFontPointSize,
122 CharacterIndex startIndex,
123 Length numberOfCharacters,
124 Vector<FontRun>& fonts);
129 } // namespace Toolkit
133 #endif // DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H