Merge "Text improvement 1. Text - Layout text & icons. * Feature added to layout...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / text / bitmap-font.h
1 #ifndef DALI_TOOLKIT_FONT_BITMAP_DEVEL_H
2 #define DALI_TOOLKIT_FONT_BITMAP_DEVEL_H
3
4 /*
5  * Copyright (c) 2019 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali-toolkit/public-api/dali-toolkit-common.h>
24 #include <string>
25
26 namespace Dali
27 {
28
29 namespace TextAbstraction
30 {
31 // Forward declarations
32 struct BitmapFont;
33 }
34
35 namespace Toolkit
36 {
37
38 namespace DevelText
39 {
40
41 /**
42  * @brief Struct that stores the needed info to create a bitmap glyph.
43  */
44
45 struct DALI_TOOLKIT_API Glyph
46 {
47   /**
48    * @brief Default constructor.
49    *
50    * Initialize the members to its defaults.
51    */
52   Glyph();
53
54   /**
55    * @brief Default destructor.
56    */
57   ~Glyph();
58
59   std::string url;  ///< The url of the glyph.
60   std::string utf8; ///< the glyph encoded in utf8
61   float ascender;   ///< The ascender. The distance from the base line to the top of the glyph.
62   float descender;  ///< The descender. The distance from the base line to the bottom of the glyph.
63 };
64
65 /**
66  * @brief Describes a bitmap font.
67  */
68 struct DALI_TOOLKIT_API BitmapFontDescription
69 {
70   /**
71    * @brief Default constructor.
72    *
73    * Initialize the members to its defaults.
74    */
75   BitmapFontDescription();
76
77   /**
78    * @brief Default destructor.
79    */
80   ~BitmapFontDescription();
81
82   std::vector<Glyph> glyphs; ///< Vector of glyphs.
83   std::string name;          ///< Name of the font.
84   float underlinePosition;   ///< The position of the underline from the base line.
85   float underlineThickness;  ///< The thickness of the underline.
86 };
87
88 /**
89  * @brief Creates a bitmap font with the given description.
90  *
91  * The @p bitmapFont output can be passed to the FontClient::GetFontId()
92  * method to load the font and get an Id.
93  *
94  * @param[in] description The description of the bitmap font.
95  * @param[out] bitmapFont A bitmap font.
96  *
97  * @note If the @e ascender and @e descender of the glyphs are zero, the @e descender value will be left as zero and all the bitmaps will be loaded to find out the @e ascender value.
98  */
99 DALI_TOOLKIT_API void CreateBitmapFont( const BitmapFontDescription& description, TextAbstraction::BitmapFont& bitmapFont );
100
101 } // namespace DevelText
102
103 } // namespace Toolkit
104
105 } // namespace Dali
106
107 #endif // DALI_TOOLKIT_TEXT_UTILS_DEVEL_H