1 #ifndef DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H
2 #define DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H
5 * Copyright (c) 2019 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>
31 namespace TextAbstraction
36 namespace Internal DALI_INTERNAL
44 * @brief Shaping provides an interface to retrieve glyphs from complex text.
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.
50 * Shaping shaping = Shaping::Get();
52 * // Shapes a number of characters with the given font id and script.
53 * const Length numberOfGlyphs = shaping.Shape( text, numberOfCharacters, fontId, script );
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 ) ) );
59 * // Retrieve the glyphs and the conversion map.
60 * shaping.GetGlyphs( glyphInfo, glyphToCharacterMap );
63 class DALI_ADAPTOR_API Shaping : public BaseHandle
69 * @brief Create an uninitialized Shaping handle.
77 * This is non-virtual since derived Handle types must not contain data or virtual methods.
82 * @brief This constructor is used by Shaping::Get().
84 * @param[in] implementation A pointer to the internal shaping object.
86 explicit DALI_INTERNAL Shaping( Internal::Shaping* implementation );
89 * @brief Retrieve a handle to the Shaping instance.
91 * @return A handle to the Shaping.
98 * Call GetGlyphs() to retrieve the glyphs.
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.
105 * @return The size of the buffer required to get the shaped text.
107 Length Shape( const Character* const text,
108 Length numberOfCharacters,
113 * Gets the shaped text data.
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.
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.
121 void GetGlyphs( GlyphInfo* glyphInfo,
122 CharacterIndex* glyphToCharacterMap );
125 } // namespace TextAbstraction
129 #endif // DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H