1 #ifndef __DALI_TOOLKIT_TEXT_VISUAL_MODEL_H__
2 #define __DALI_TOOLKIT_TEXT_VISUAL_MODEL_H__
5 * Copyright (c) 2015 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/public-api/common/intrusive-ptr.h>
25 #include <dali-toolkit/public-api/text/text-definitions.h>
39 typedef IntrusivePtr<VisualModel> VisualModelPtr;
42 * @brief A visual text model contains layout specific information.
45 * - A series of glyphs in visual order i.e. after the bidirectional reordering.
46 * - The position of each glyph within a 2D bounding box.
48 class VisualModel : public RefObject
53 * @brief Create a new instance of a VisualModel.
55 * @return A pointer to a new VisualModel.
57 static VisualModelPtr New();
62 * @brief Replaces any glyphs previously set.
64 * @param[in] glyphs An array of glyphs in the visual order.
65 * @param[in] characterIndices An array containing the first character in the logical model that each glyph relates to.
66 * @param[in] charactersPerGlyph An array of containing the number of characters per glyph.
67 * @param[in] numberOfGlyphs The number of glyphs.
69 void SetGlyphs( const GlyphInfo* glyphs,
70 const CharacterIndex* characterIndices,
71 const Length* charactersPerGlyph,
72 Length numberOfGlyphs );
75 * Retrieves the number of glyphs.
77 * @return The number of glyphs.
79 Length GetNumberOfGlyphs() const;
82 * @brief Retrieves glyphs in the given buffer.
84 * The size of the @p glyphs buffer needs to be big enough to copy the @p numberOfGlyphs.
85 * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
86 * @param[in] glyphIndex Index to the first glyph.
87 * @param[in] numberOfGlyphs Number of glyphs to be copied.
89 void GetGlyphs( GlyphIndex glyphIndex,
91 Length numberOfGlyphs ) const;
93 // Character <--> Glyph conversion
96 * @brief Retrieves the first character in the logical model which a glyph represents.
98 * @note After shaping several characters may be represented by the same glyph.
99 * Alternatively several glyphs may be required to display a character.
100 * @param[in] glyphIndex The glyph index.
101 * @return The character index.
103 CharacterIndex GetCharacterIndex( GlyphIndex glyphIndex ) const;
106 * @brief Query the number of characters the glyph represents.
108 * @param[in] glyphIndex The glyph index.
109 * @return The number of characters represented by the glyph.
111 Length GetCharactersPerGlyph( GlyphIndex glyphIndex ) const;
114 * Retrieves the first glyph in the visual model which represents a given character.
116 * @note After shaping several characters may be represented by the same glyph.
117 * Alternatively several glyphs may be required to display a character.
118 * @param[in] characterIndex The character index.
119 * @return The glyph index.
121 GlyphIndex GetGlyphIndex( CharacterIndex characterIndex ) const;
123 // Position interface
126 * @brief Replaces any glyph positions previously set.
128 * @param[in] glyphPositions An array of visual positions for each glyph.
129 * @param[in] numberOfGlyphs The number of positions.
131 void SetGlyphPositions( const Vector2* glyphPositions,
132 Length numberOfGlyphs );
135 * @brief Retrieves the glyph positions.
137 * @pre The size of the @p positions buffer needs to be big enough to copy the @p numberOfGlyphs positions.
138 * @param[in] glyphIndex Index to the first glyph position.
139 * @param[out] glyphPositions Pointer to a buffer where the glyph positions are copied.
140 * @param[in] numberOfGlyphs The number of positions to be copied.
142 void GetGlyphPositions( GlyphIndex glyphIndex,
143 Vector2* glyphPositions,
144 Length numberOfGlyphs ) const;
149 * @brief A reference counted object may only be deleted by calling Unreference().
151 virtual ~VisualModel();
156 * @brief Private constructor.
161 VisualModel( const VisualModel& handle );
164 VisualModel& operator=( const VisualModel& handle );
173 } // namespace Toolkit
177 #endif // __DALI_TOOLKIT_TEXT_VISUAL_MODEL_H__