Merge branch 'devel/master' into sandbox/dkdk/tizen
[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) 2020 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 namespace Dali
31 {
32 namespace TextAbstraction
33 {
34 /**
35  * @brief Struct that stores the needed info to create a bitmap glyph.
36  *
37  * BitmapGlyph objects need to be added to a BitmapFont.
38  */
39 struct DALI_ADAPTOR_API BitmapGlyph
40 {
41   /**
42    * @brief Default constructor.
43    *
44    * Initialize the members to its defaults.
45    */
46   BitmapGlyph();
47
48   /**
49    * @brief Constructor.
50    *
51    * Initialize the members with the given values.
52    *
53    * @param[in] url The url of the bitmap for that glyph.
54    * @param[in] utf32 The utf32 codification of the glyph.
55    * @param[in] ascender The ascender of the glyph.
56    * @param[in] descender The descender of the glyph.
57    */
58   BitmapGlyph(const std::string& url, GlyphIndex utf32, float ascender, float descender);
59
60   /**
61    * @brief Default destructor.
62    */
63   ~BitmapGlyph();
64
65   std::string url;       ///< The url of the glyph's bitmap.
66   GlyphIndex  utf32;     ///< The id of the glyph encoded in utf32.
67   float       ascender;  ///< The ascender in pixels. The distance from the base line to the top of the glyph.
68   float       descender; ///< The descender in pixels. The distance from the base line to the bottom of the glyph.
69 };
70
71 /**
72  * @brief Struct that stores the needed info to create a bitmap font.
73  *
74  * A bitmap font can be created by calling FontClient::GetFontId( const BitmapFont& ).
75  */
76 struct DALI_ADAPTOR_API BitmapFont
77 {
78   /**
79    * @brief Default constructor.
80    *
81    * Initialize the members to its defaults but the @e underlineThickness which is initilized to 1 pixel.
82    */
83   BitmapFont();
84
85   /**
86    * @brief Default destructor.
87    */
88   ~BitmapFont();
89
90   std::vector<BitmapGlyph> glyphs;             ///< The glyphs of the font.
91   std::string              name;               ///< The name of the font.
92   float                    ascender;           ///< The ascender in pixels. Maximum ascender of all the glyphs.
93   float                    descender;          ///< The descender in pixels. Minimum descender of all the glyphs.
94   float                    underlinePosition;  ///< The position in pixels of the underline from the base line.
95   float                    underlineThickness; ///< The thickness in pixels of the underline.
96   bool                     isColorFont : 1;    ///< Whether the glyphs of this font have their own colors.
97 };
98
99 } // namespace TextAbstraction
100
101 } // namespace Dali
102
103 #endif // DALI_TEXT_ABSTRACTION_BITMAP_FONT_H