Make GlyphBufferData as another class
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / hyphenation.h
1 #ifndef DALI_PLATFORM_TEXT_ABSTRACTION_HYPHENATION_H
2 #define DALI_PLATFORM_TEXT_ABSTRACTION_HYPHENATION_H
3
4 /*
5  * Copyright (c) 2021 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 // INTERNAL INCLUDES
22 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
23 #include <dali/public-api/dali-adaptor-common.h>
24
25 // EXTERNAL INCLUDES
26 #include <dali/public-api/object/base-handle.h>
27
28 namespace Dali
29 {
30 namespace TextAbstraction
31 {
32 namespace Internal DALI_INTERNAL
33 {
34 class Hyphenation;
35
36 } // namespace DALI_INTERNAL
37
38 /**
39  * @brief Hyphenation provides an interface to retrieve possible hyphenation of the text.
40  *
41  * This module get the hyphen positions for a word.
42  * To get the hyphen positions it needs to load the dictionary for the word language.
43  * also it need the word to be send using the correct encoding which can be known using
44  *
45  * @code
46  * Hyphenation hyphenation = Hyphenation::Get();
47  *
48  * Character* text = "Hyphenation";
49  *
50  * // get a vector of booleans that indicates possible hyphen locations.
51  * Vector<bool> *hyphens = hyphenation.GetWordHyphens(text, 11, "en_US");
52  *
53  * @endcode
54  */
55 class DALI_ADAPTOR_API Hyphenation : public BaseHandle
56 {
57 public:
58   /**
59    * @brief Create an uninitialized Hyphenation handle.
60    *
61    */
62   Hyphenation();
63
64   /**
65    * @brief Destructor
66    *
67    * This is non-virtual since derived Handle types must not contain data or virtual methods.
68    */
69   ~Hyphenation();
70
71   /**
72    * @brief This constructor is used by Hyphenation::Get().
73    *
74    * @param[in] implementation A pointer to the internal hyphenation object.
75    */
76   explicit DALI_INTERNAL Hyphenation(Internal::Hyphenation* implementation);
77
78   /**
79    * @brief Retrieve a handle to the Hyphenation instance.
80    *
81    * @return A handle to the Hyphenation.
82    */
83   static Hyphenation Get();
84
85   /**
86    *
87    * Gets the encoding of the dictionary for the given language
88    *
89    * @param[in] lang language to get encoding for (en_US).
90    *
91    * @return The encoding of the language (UTF-32).
92    */
93   const char* GetDictionaryEncoding(const char* lang);
94
95   /**
96    * Gets a vector booleans that indicates possible hyphen locations.
97    *
98    * @param[in] word the word to get possible hyphens for.
99    * @param[in] wordSize the word size in bytes.
100    * @param[in] lang the language for the word
101    *
102    * @return vector of boolean, true if possible to hyphenate at this character position.
103    */
104   Vector<bool> GetWordHyphens(const char* word,
105                               Length      wordSize,
106                               const char* lang);
107 };
108
109 } // namespace TextAbstraction
110
111 } // namespace Dali
112
113 #endif // DALI_PLATFORM_TEXT_ABSTRACTION_HYPHENATION_H