TextModel - Update the color runs.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / multi-language-support.h
1 #ifndef __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H__
2 #define __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/object/base-handle.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/text/font-run.h>
27 #include <dali-toolkit/internal/text/font-description-run.h>
28 #include <dali-toolkit/internal/text/script-run.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Text
37 {
38
39 namespace Internal DALI_INTERNAL
40 {
41
42 class MultilanguageSupport;
43
44 } // Internal
45
46 /**
47  * @brief Sets the character's scripts to the model and validates the fonts set by the user or assigns default ones.
48  */
49 class MultilanguageSupport : public BaseHandle
50 {
51 public:
52
53   /**
54    * @brief Create an uninitialized MultilanguageSupport handle.
55    */
56   MultilanguageSupport();
57
58   /**
59    * @brief Destructor
60    *
61    * This is non-virtual since derived Handle types must not contain data or virtual methods.
62    */
63   ~MultilanguageSupport();
64
65   /**
66    * @brief This constructor is used by MultilanguageSupport::Get().
67    *
68    * @param[in] implementation A pointer to the internal multi-language support object.
69    */
70   explicit DALI_INTERNAL MultilanguageSupport( Internal::MultilanguageSupport* implementation );
71
72   /**
73    * @brief Retrieve a handle to the MultilanguageSupport instance.
74    *
75    * @return A handle to the MultilanguageSupport.
76    */
77   static MultilanguageSupport Get();
78
79   /**
80    * @brief Sets the scripts of the whole text.
81    *
82    * Scripts are used to validate and set default fonts and to shape the text in further steps.
83    *
84    * Some characters (like white spaces) are valid for many scripts. The rules to set a script
85    * for them are:
86    * - If they are at the begining of a paragraph they get the script of the first character with
87    *   a defined script. If they are at the end, they get the script of the last one.
88    * - If they are between two scripts with the same direction, they get the script of the previous
89    *   character with a defined script. If the two scripts have different directions, they get the
90    *   script of the first character of the paragraph with a defined script.
91    *
92    * @param[in] text Vector of UTF-32 characters.
93    * @param[in] startIndex The character from where the script info is set.
94    * @param[in] numberOfCharacters The number of characters to set the script.
95    * @param[out] scripts Vector containing the script runs for the whole text.
96    */
97   void SetScripts( const Vector<Character>& text,
98                    CharacterIndex startIndex,
99                    Length numberOfCharacters,
100                    Vector<ScriptRun>& scripts );
101
102   /**
103    * @brief Validates the character's font of the whole text.
104    *
105    * This method ensures all characters are going to be rendered using an appropriate font. Provided a valid font
106    * exists in the platform.
107    *
108    * For those characters with no font set, it sets a default one.
109    *
110    * If a font has been set by the application developer, this method checks if the font supports the character.
111    * If it doesn't, this method replaces it by a default one.
112    *
113    * @param[in] text Vector of UTF-32 characters.
114    * @param[in] scripts Vector containing the script runs for the whole text.
115    * @param[in] fontDescriptions The fonts set by the application developers.
116    * @param[in] defaultFontId The default font's id.
117    * @param[in] startIndex The character from where the font info is set.
118    * @param[in] numberOfCharacters The number of characters to set the font.
119    * @param[out] fonts The validated fonts.
120    */
121   void ValidateFonts( const Vector<Character>& text,
122                       const Vector<ScriptRun>& scripts,
123                       const Vector<FontDescriptionRun>& fontDescriptions,
124                       FontId defaultFontId,
125                       CharacterIndex startIndex,
126                       Length numberOfCharacters,
127                       Vector<FontRun>& fonts );
128 };
129
130 } // namespace Text
131
132 } // namespace Toolkit
133
134 } // namespace Dali
135
136 #endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H__