Text improvement
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / bitmap-font.h
1 #ifndef DALI_TEXT_ABSTRACTION_BITMAP_FONT_H
2 #define DALI_TEXT_ABSTRACTION_BITMAP_FONT_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/dali-common.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/dali-adaptor-common.h>
25 #include <string>
26
27 // INTERNAL INCLUDES
28 #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
29
30
31
32 namespace Dali
33 {
34
35 namespace TextAbstraction
36 {
37
38 /**
39  * @brief Struct that stores the needed info to create a bitmap glyph.
40  *
41  * BitmapGlyph objects need to be added to a BitmapFont.
42  */
43 struct DALI_ADAPTOR_API BitmapGlyph
44 {
45   /**
46    * @brief Default constructor.
47    *
48    * Initialize the members to its defaults.
49    */
50   BitmapGlyph();
51
52   /**
53    * @brief Constructor.
54    *
55    * Initialize the members with the given values.
56    *
57    * @param[in] url The url of the bitmap for that glyph.
58    * @param[in] utf32 The utf32 codification of the glyph.
59    * @param[in] ascender The ascender of the glyph.
60    * @param[in] descender The descender of the glyph.
61    */
62   BitmapGlyph( const std::string& url, GlyphIndex utf32, float ascender, float descender );
63
64   /**
65    * @brief Default destructor.
66    */
67   ~BitmapGlyph();
68
69   std::string url;  ///< The url of the glyph's bitmap.
70   GlyphIndex utf32; ///< The id of the glyph encoded in utf32.
71   float ascender;   ///< The ascender in pixels. The distance from the base line to the top of the glyph.
72   float descender;  ///< The descender in pixels. The distance from the base line to the bottom of the glyph.
73 };
74
75 /**
76  * @brief Struct that stores the needed info to create a bitmap font.
77  *
78  * A bitmap font can be created by calling FontClient::GetFontId( const BitmapFont& ).
79  */
80 struct DALI_ADAPTOR_API BitmapFont
81 {
82   /**
83    * @brief Default constructor.
84    *
85    * Initialize the members to its defaults but the @e underlineThickness which is initilized to 1 pixel.
86    */
87   BitmapFont();
88
89   /**
90    * @brief Default destructor.
91    */
92   ~BitmapFont();
93
94   std::vector<BitmapGlyph> glyphs; ///< The glyphs of the font.
95   std::string name;                ///< The name of the font.
96   float ascender;                  ///< The ascender in pixels. Maximum ascender of all the glyphs.
97   float descender;                 ///< The descender in pixels. Minimum descender of all the glyphs.
98   float underlinePosition;         ///< The position in pixels of the underline from the base line.
99   float underlineThickness;        ///< The thickness in pixels of the underline.
100 };
101
102 } // namespace TextAbstraction
103
104 } // namespace Dali
105
106 #endif // DALI_TEXT_ABSTRACTION_BITMAP_FONT_H