Changes for std::vector removal from api
[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/script-run.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Text
36 {
37
38 namespace Internal DALI_INTERNAL
39 {
40
41 class MultilanguageSupport;
42
43 } // Internal
44
45 class LogicalModel;
46
47 /**
48  * @brief Sets the character's scripts to the model and validates the fonts set by the user or assigns default ones.
49  */
50 class MultilanguageSupport : public BaseHandle
51 {
52 public:
53
54   /**
55    * @brief Create an uninitialized MultilanguageSupport handle.
56    */
57   MultilanguageSupport();
58
59   /**
60    * @brief Destructor
61    *
62    * This is non-virtual since derived Handle types must not contain data or virtual methods.
63    */
64   ~MultilanguageSupport();
65
66   /**
67    * @brief This constructor is used by MultilanguageSupport::Get().
68    *
69    * @param[in] implementation A pointer to the internal multi-language support object.
70    */
71   explicit DALI_INTERNAL MultilanguageSupport( Internal::MultilanguageSupport* implementation );
72
73   /**
74    * @brief Retrieve a handle to the MultilanguageSupport instance.
75    *
76    * @return A handle to the MultilanguageSupport.
77    */
78   static MultilanguageSupport Get();
79
80   /**
81    * @brief Sets the scripts of the whole text.
82    *
83    * Scripts are used to validate and set default fonts and to shape the text in further steps.
84    *
85    * Some characters (like white spaces) are valid for many scripts. The rules to set a script
86    * for them are:
87    * - If they are at the begining of a paragraph they get the script of the first character with
88    *   a defined script. If they are at the end, they get the script of the last one.
89    * - If they are between two scripts with the same direction, they get the script of the previous
90    *   character with a defined script. If the two scripts have different directions, they get the
91    *   script of the first character of the paragraph with a defined script.
92    *
93    * @param[in] text Vector of UTF-32 characters.
94    * @param[in] lineBreakInfo Vector with the line break info.
95    * @param[out] scripts Vector containing the script runs for the whole text.
96    */
97   void SetScripts( const Vector<Character>& text,
98                    const Vector<LineBreakInfo>& lineBreakInfo,
99                    Vector<ScriptRun>& scripts );
100
101   /**
102    * Replaces the scrips of the given range of characters.
103    *
104    * @pre The @p model needs to have a text set.
105    *
106    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
107    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
108    *
109    * @param[in,out] model The text's logical model.
110    * @param[in] characterIndex Index to the first character.
111    * @param[in] numberOfCharactersToRemove The number of characters removed from the text.
112    * @param[in] numberOfCharactersToInsert The number of characters inserted in the text.
113    */
114   void ReplaceScripts( LogicalModel& model,
115                        CharacterIndex characterIndex,
116                        Length numberOfCharactersToRemove,
117                        Length numberOfCharactersToInsert );
118
119   /**
120    * @brief Validates the character's font of the whole text.
121    *
122    * It may update fonts set by application developers.
123    *
124    * This method ensures all characters are going to be rendered using an appropriate font. Provided a valid font
125    * exists in the platform.
126    *
127    * For those characters with no font set, it sets a default one.
128    *
129    * If a font has been set by the application developer, this method checks if the font supports the character.
130    * If it doesn't, this method replaces it by a default one.
131    *
132    * @param[in] text Vector of UTF-32 characters.
133    * @param[in] scripts Vector containing the script runs for the whole text.
134    * @param[in,out] fonts Initially contains the fonts set by the application developers. Returns the validated fonts.
135    */
136   void ValidateFonts( const Vector<Character>& text,
137                       const Vector<ScriptRun>& scripts,
138                       Vector<FontRun>& fonts );
139
140   /**
141    * Validates the character's font of the given range of characters.
142    *
143    * It may update fonts set by the mark-up processor.
144    * It sets default fonts based on the script to those characters without a font set.
145    *
146    * @pre The @p model needs to have a text set.
147    * @pre The @p model needs to have the scripts set.
148    *
149    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
150    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
151    *
152    * @param[in,out] model The text's logical model.
153    * @param[in] characterIndex Index to the first character.
154    * @param[in] numberOfCharactersToRemove The number of characters removed from the text.
155    * @param[in] numberOfCharactersToInsert The number of characters inserted in the text.
156    */
157   void ValidateFonts( LogicalModel& model,
158                       CharacterIndex characterIndex,
159                       Length numberOfCharactersToRemove,
160                       Length numberOfCharactersToInsert );
161 };
162
163 } // namespace Text
164
165 } // namespace Toolkit
166
167 } // namespace Dali
168
169 #endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H__