1 #ifndef DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H
2 #define DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H
5 * Copyright (c) 2020 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/devel-api/text-abstraction/emoji-helper.h>
23 #include <dali/devel-api/text-abstraction/script.h>
24 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
27 #include <dali/public-api/object/base-handle.h>
31 namespace TextAbstraction
35 namespace Internal DALI_INTERNAL
39 } // namespace DALI_INTERNAL
42 * @brief Shaping provides an interface to retrieve glyphs from complex text.
44 * This module shapes text for a unique font id and script. If the text contains different fonts and scripts
45 * it needs to be split in runs of consecutive characters with the same font id and script.
48 * Shaping shaping = Shaping::Get();
50 * // Shapes a number of characters with the given font id and script.
51 * const Length numberOfGlyphs = shaping.Shape( text, numberOfCharacters, fontId, script );
53 * // Allocate memory to retrieve the glyphs and the character to glyph conversion map.
54 * GlyphInfo* glyphInfo = reinterpret_cast<GlyphInfo*>( malloc( numberOfGlyphs * sizeof( GlyphInfo ) ) );
55 * CharacterIndex* glyphToCharacterMap = reinterpret_cast<CharacterIndex*>( malloc( numberOfGlyphs * sizeof( CharacterIndex ) ) );
57 * // Retrieve the glyphs and the conversion map.
58 * shaping.GetGlyphs( glyphInfo, glyphToCharacterMap );
61 class DALI_ADAPTOR_API Shaping : public BaseHandle
65 * @brief Create an uninitialized Shaping handle.
73 * This is non-virtual since derived Handle types must not contain data or virtual methods.
78 * @brief This constructor is used by Shaping::Get().
80 * @param[in] implementation A pointer to the internal shaping object.
82 explicit DALI_INTERNAL Shaping(Internal::Shaping* implementation);
85 * @brief Retrieve a handle to the Shaping instance.
87 * @return A handle to the Shaping.
94 * Call GetGlyphs() to retrieve the glyphs.
96 * @param[in] text Pointer to the first character of the text coded in UTF32.
97 * @param[in] numberOfCharacters The number of characters to be shaped
98 * @param[in] fontId The font to be used to shape the text.
99 * @param[in] script The text's script.
101 * @return The size of the buffer required to get the shaped text.
103 Length Shape(const Character* const text,
104 Length numberOfCharacters,
109 * Gets the shaped text data.
111 * @pre @p glyphInfo and @p glyphToCharacterMap must have enough space allocated for the number of glyphs.
112 * Call first Shape() to shape the text and get the number of glyphs.
114 * @param[out] glyphInfo Vector with indices to the glyph within the font, glyph's metrics and advance.
115 * @param[out] glyphToCharacterMap The glyph to character conversion map.
117 void GetGlyphs(GlyphInfo* glyphInfo,
118 CharacterIndex* glyphToCharacterMap);
121 } // namespace TextAbstraction
125 #endif // DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H