Revert "[Tizen] Add DALi Autofill implementation"
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / shaping.h
1 #ifndef DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H
2 #define DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H
3
4 /*
5  * Copyright (c) 2019 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/script.h>
23 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
24
25 // EXTERNAL INCLUDES
26 #include <dali/public-api/object/base-handle.h>
27
28 namespace Dali
29 {
30
31 namespace TextAbstraction
32 {
33
34 struct GlyphInfo;
35
36 namespace Internal DALI_INTERNAL
37 {
38
39 class Shaping;
40
41 } // Internal
42
43 /**
44  * @brief Shaping provides an interface to retrieve glyphs from complex text.
45  *
46  * This module shapes text for a unique font id and script. If the text contains different fonts and scripts
47  * it needs to be split in runs of consecutive characters with the same font id and script.
48  *
49  * @code
50  * Shaping shaping = Shaping::Get();
51  *
52  * // Shapes a number of characters with the given font id and script.
53  * const Length numberOfGlyphs = shaping.Shape( text, numberOfCharacters, fontId, script );
54  *
55  * // Allocate memory to retrieve the glyphs and the character to glyph conversion map.
56  * GlyphInfo* glyphInfo = reinterpret_cast<GlyphInfo*>( malloc( numberOfGlyphs * sizeof( GlyphInfo ) ) );
57  * CharacterIndex* glyphToCharacterMap = reinterpret_cast<CharacterIndex*>( malloc( numberOfGlyphs * sizeof( CharacterIndex ) ) );
58  *
59  * // Retrieve the glyphs and the conversion map.
60  * shaping.GetGlyphs( glyphInfo, glyphToCharacterMap );
61  * @endcode
62  */
63 class DALI_ADAPTOR_API Shaping : public BaseHandle
64 {
65
66 public:
67
68   /**
69    * @brief Create an uninitialized Shaping handle.
70    *
71    */
72   Shaping();
73
74   /**
75    * @brief Destructor
76    *
77    * This is non-virtual since derived Handle types must not contain data or virtual methods.
78    */
79   ~Shaping();
80
81   /**
82    * @brief This constructor is used by Shaping::Get().
83    *
84    * @param[in] implementation A pointer to the internal shaping object.
85    */
86   explicit DALI_INTERNAL Shaping( Internal::Shaping* implementation );
87
88   /**
89    * @brief Retrieve a handle to the Shaping instance.
90    *
91    * @return A handle to the Shaping.
92    */
93   static Shaping Get();
94
95   /**
96    * Shapes the text.
97    *
98    * Call GetGlyphs() to retrieve the glyphs.
99    *
100    * @param[in] text Pointer to the first character of the text coded in UTF32.
101    * @param[in] numberOfCharacters The number of characters to be shaped
102    * @param[in] fontId The font to be used to shape the text.
103    * @param[in] script The text's script.
104    *
105    * @return The size of the buffer required to get the shaped text.
106    */
107   Length Shape( const Character* const text,
108                 Length numberOfCharacters,
109                 FontId fontId,
110                 Script script );
111
112   /**
113    * Gets the shaped text data.
114    *
115    * @pre @p glyphInfo and @p glyphToCharacterMap must have enough space allocated for the number of glyphs.
116    * Call first Shape() to shape the text and get the number of glyphs.
117    *
118    * @param[out] glyphInfo Vector with indices to the glyph within the font, glyph's metrics and advance.
119    * @param[out] glyphToCharacterMap The glyph to character conversion map.
120    */
121   void GetGlyphs( GlyphInfo* glyphInfo,
122                   CharacterIndex* glyphToCharacterMap );
123 };
124
125 } // namespace TextAbstraction
126
127 } // namespace Dali
128
129 #endif // DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H