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/script.h>
23 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
26 #include <dali/public-api/object/base-handle.h>
30 namespace TextAbstraction
34 namespace Internal DALI_INTERNAL
38 } // namespace DALI_INTERNAL
41 * @brief Shaping provides an interface to retrieve glyphs from complex text.
43 * This module shapes text for a unique font id and script. If the text contains different fonts and scripts
44 * it needs to be split in runs of consecutive characters with the same font id and script.
47 * Shaping shaping = Shaping::Get();
49 * // Shapes a number of characters with the given font id and script.
50 * const Length numberOfGlyphs = shaping.Shape( text, numberOfCharacters, fontId, script );
52 * // Allocate memory to retrieve the glyphs and the character to glyph conversion map.
53 * GlyphInfo* glyphInfo = reinterpret_cast<GlyphInfo*>( malloc( numberOfGlyphs * sizeof( GlyphInfo ) ) );
54 * CharacterIndex* glyphToCharacterMap = reinterpret_cast<CharacterIndex*>( malloc( numberOfGlyphs * sizeof( CharacterIndex ) ) );
56 * // Retrieve the glyphs and the conversion map.
57 * shaping.GetGlyphs( glyphInfo, glyphToCharacterMap );
60 class DALI_ADAPTOR_API Shaping : public BaseHandle
64 * @brief Create an uninitialized Shaping handle.
72 * This is non-virtual since derived Handle types must not contain data or virtual methods.
77 * @brief This constructor is used by Shaping::Get().
79 * @param[in] implementation A pointer to the internal shaping object.
81 explicit DALI_INTERNAL Shaping(Internal::Shaping* implementation);
84 * @brief Retrieve a handle to the Shaping instance.
86 * @return A handle to the Shaping.
93 * Call GetGlyphs() to retrieve the glyphs.
95 * @param[in] text Pointer to the first character of the text coded in UTF32.
96 * @param[in] numberOfCharacters The number of characters to be shaped
97 * @param[in] fontId The font to be used to shape the text.
98 * @param[in] script The text's script.
100 * @return The size of the buffer required to get the shaped text.
102 Length Shape(const Character* const text,
103 Length numberOfCharacters,
108 * Gets the shaped text data.
110 * @pre @p glyphInfo and @p glyphToCharacterMap must have enough space allocated for the number of glyphs.
111 * Call first Shape() to shape the text and get the number of glyphs.
113 * @param[out] glyphInfo Vector with indices to the glyph within the font, glyph's metrics and advance.
114 * @param[out] glyphToCharacterMap The glyph to character conversion map.
116 void GetGlyphs(GlyphInfo* glyphInfo,
117 CharacterIndex* glyphToCharacterMap);
120 } // namespace TextAbstraction
124 #endif // DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H