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>
23 #include <dali/public-api/object/ref-object.h>
24 #include <dali-toolkit/public-api/text/text-definitions.h>
38 typedef IntrusivePtr<VisualModel> VisualModelPtr;
41 * @brief A visual text model contains layout specific information.
44 * - A series of glyphs in visual order i.e. after the bidirectional reordering.
45 * - The position of each glyph within a 2D bounding box.
47 class VisualModel : public RefObject
52 * @brief Create a new instance of a VisualModel.
54 * @return A pointer to a new VisualModel.
56 static VisualModelPtr New();
61 * @brief Replaces any glyphs previously set.
63 * @param[in] glyphs An array of glyphs in the visual order.
64 * @param[in] characterIndices An array containing the first character in the logical model that each glyph relates to.
65 * @param[in] charactersPerGlyph An array containing the number of characters per glyph.
66 * @param[in] numberOfGlyphs The number of glyphs.
68 void SetGlyphs( const GlyphInfo* glyphs,
69 const CharacterIndex* characterIndices,
70 const Length* charactersPerGlyph,
71 Length numberOfGlyphs );
74 * Retrieves the number of glyphs.
76 * @return The number of glyphs.
78 Length GetNumberOfGlyphs() const;
81 * @brief Retrieves glyphs in the given buffer.
83 * The size of the @p glyphs buffer needs to be big enough to copy the @p numberOfGlyphs.
84 * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
85 * @param[in] glyphIndex Index to the first glyph.
86 * @param[in] numberOfGlyphs Number of glyphs to be copied.
88 void GetGlyphs( GlyphIndex glyphIndex,
90 Length numberOfGlyphs ) const;
92 // Character <--> Glyph conversion
95 * @brief Retrieves the first character in the logical model which a glyph represents.
97 * @note After shaping several characters may be represented by the same glyph.
98 * Alternatively several glyphs may be required to display a character.
99 * @param[in] glyphIndex The glyph index.
100 * @return The character index.
102 CharacterIndex GetCharacterIndex( GlyphIndex glyphIndex ) const;
105 * @brief Query the number of characters the glyph represents.
107 * @param[in] glyphIndex The glyph index.
108 * @return The number of characters represented by the glyph.
110 Length GetCharactersPerGlyph( GlyphIndex glyphIndex ) const;
113 * Retrieves the first glyph in the visual model which represents a given character.
115 * @note After shaping several characters may be represented by the same glyph.
116 * Alternatively several glyphs may be required to display a character.
117 * @param[in] characterIndex The character index.
118 * @return The glyph index.
120 GlyphIndex GetGlyphIndex( CharacterIndex characterIndex ) const;
122 // Position interface
125 * @brief Replaces any glyph positions previously set.
127 * @param[in] glyphPositions An array of visual positions for each glyph.
128 * @param[in] numberOfGlyphs The number of positions.
130 void SetGlyphPositions( const Vector2* glyphPositions,
131 Length numberOfGlyphs );
134 * @brief Retrieves the glyph positions.
136 * @pre The size of the @p positions buffer needs to be big enough to copy the @p numberOfGlyphs positions.
137 * @param[in] glyphIndex Index to the first glyph position.
138 * @param[out] glyphPositions Pointer to a buffer where the glyph positions are copied.
139 * @param[in] numberOfGlyphs The number of positions to be copied.
141 void GetGlyphPositions( GlyphIndex glyphIndex,
142 Vector2* glyphPositions,
143 Length numberOfGlyphs ) const;
148 * @brief A reference counted object may only be deleted by calling Unreference().
150 virtual ~VisualModel();
155 * @brief Private constructor.
160 VisualModel( const VisualModel& handle );
163 VisualModel& operator=( const VisualModel& handle );
172 } // namespace Toolkit
176 #endif // __DALI_TOOLKIT_TEXT_VISUAL_MODEL_H__