Fixed clipboard disappearing issue on selection
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / glyph-metrics-helper.h
1 #ifndef __DALI_TOOLKIT_TEXT_GLYPH_METRICS_HELPER_H__
2 #define __DALI_TOOLKIT_TEXT_GLYPH_METRICS_HELPER_H__
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/text/metrics.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Text
31 {
32
33 /**
34  * @brief Some characters can be shaped in more than one glyph.
35  * This struct is used to retrieve metrics from these group of glyphs.
36  */
37 struct GlyphMetrics
38 {
39   GlyphMetrics()
40   : fontId( 0u ),
41     fontHeight( 0.f ),
42     width( 0.f ),
43     advance( 0.f ),
44     ascender( 0.f ),
45     xBearing( 0.f )
46   {}
47
48   ~GlyphMetrics()
49   {}
50
51   FontId fontId;     ///< The font id of the glyphs.
52   float  fontHeight; ///< The font's height of those glyphs.
53   float  width;      ///< The sum of all the widths of all the glyphs.
54   float  advance;    ///< The sum of all the advances of all the glyphs.
55   float  ascender;   ///< The font's ascender.
56   float  xBearing;   ///< The x bearing of the first glyph.
57 };
58
59 /**
60  * @brief Returns the number of glyphs of a group of glyphs.
61  *
62  * @param[in] glyphIndex The first glyph of the group.
63  * @param[in] lastGlyphPlusOne Index to one after the last glyph.
64  * @param[in] charactersPerGlyphBuffer The number of characters per glyph buffer.
65  *
66  * @return The number of glyphs of the group.
67  */
68 Length GetNumberOfGlyphsOfGroup( GlyphIndex glyphIndex,
69                                  GlyphIndex lastGlyphPlusOne,
70                                  const Length* const charactersPerGlyphBuffer );
71
72 /**
73  * @brief Get some glyph's metrics of a group of glyphs formed as a result of shaping one character.
74  *
75  * @param[in] glyphIndex The index to the first glyph.
76  * @param[in] numberOfGlyphs The number of glyphs.
77  * @param[out] glyphMetrics Some glyph metrics (font height, advance, ascender and x bearing).
78  * @param[in] glyphsBuffer The glyphs buffer.
79  * @param[in] metrics Used to access metrics from FontClient.
80  */
81 void GetGlyphsMetrics( GlyphIndex glyphIndex,
82                        Length numberOfGlyphs,
83                        GlyphMetrics& glyphMetrics,
84                        const GlyphInfo* const glyphsBuffer,
85                        MetricsPtr& metrics );
86
87 } // namespace Text
88
89 } // namespace Toolkit
90
91 } // namespace Dali
92
93 #endif // __DALI_TOOLKIT_TEXT_GLYPH_METRICS_HELPER_H__