8fd59a00313c153e77e085f5b967cd135e681eef
[platform/core/uifw/dali-core.git] / capi / dali / public-api / text / font-parameters.h
1 #ifndef __DALI_FONT_PARAMETERS_H__
2 #define __DALI_FONT_PARAMETERS_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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  * @addtogroup CAPI_DALI_FRAMEWORK
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/object/base-handle.h>
27 #include <dali/public-api/text/text.h>
28
29 namespace Dali DALI_IMPORT_API
30 {
31
32 /**
33  * Font size in points.
34  * This reduces ambiguity when using methods which accept size in pixels or points.
35  */
36 struct PointSize
37 {
38   /**
39    * Create size in points.
40    * @param[in] value The value in points.
41    */
42   explicit PointSize(float value);
43
44   operator float() const;
45
46   /**
47    * Equality operator.
48    * @param pointSize The point size to be compared.
49    * @return \e true if \e pointSize is equal to the point size stored in this object.
50    */
51   bool operator==( PointSize pointSize );
52
53   /**
54    * Inequality operator.
55    * @param pointSize The point size to be compared.
56    * @return \e true if \e pointSize is not equal to the point size stored in this object.
57    */
58   bool operator!=( PointSize pointSize );
59
60   float value; ///< The value in points
61 };
62
63 /**
64  * Font size in pixels.
65  * This reduces ambiguity when using methods which accept size in pixels or points.
66  */
67 struct PixelSize
68 {
69   /**
70    * Create size in pixels.
71    * @param[in] value The value in pixels.
72    */
73   explicit PixelSize(unsigned int value);
74
75   operator unsigned int() const;
76
77   unsigned int value; ///< The value in pixels
78 };
79
80 struct CapsHeight
81 {
82   explicit CapsHeight( unsigned int value);
83
84   operator unsigned int() const;
85
86   unsigned int value;
87 };
88
89 /**
90  * Encapsulates all font parameters.
91  */
92 struct FontParameters
93 {
94   /**
95    * Default constructor. Default system font family name, default system font style and default system size
96    * will be used to build the font.
97    */
98   FontParameters();
99
100   /**
101    * Contructor. Creates font parameters with the given family's name, style and size in points from the font requested.
102    * @param[in] familyName The family's name of the font requested.
103    * @param[in] style The style of the font requested.
104    * @param[in] size The size of the font requested in points.
105    */
106   FontParameters( const std::string& familyName, const std::string& style, PointSize size );
107
108   /**
109    * Contructor. Creates font parameters with the given family's name, style and size in pixels from the font requested.
110    * @param[in] familyName The family's name of the font requested.
111    * @param[in] style The style of the font requested.
112    * @param[in] size The size of the font requested in pixels.
113    */
114   FontParameters( const std::string& familyName, const std::string& style, PixelSize size );
115
116   /**
117    * Contructor. Creates font parameters with the given family's name, style and the caps-height size in pixels from the font requested.
118    * @param[in] familyName The family's name of the font requested.
119    * @param[in] style The style of the font requested.
120    * @param[in] size The caps-height of the font requested in pixels.
121    */
122   FontParameters( const std::string& familyName, const std::string& style, CapsHeight size );
123
124   /**
125    * Destructor.
126    * Destroys the internal implementation.
127    */
128   ~FontParameters();
129
130   /**
131    * Copy constructor.
132    * Reset the internal implementation with new given values.
133    * @param[in] parameters The new font parameters.
134    */
135   FontParameters( const FontParameters& parameters );
136
137   /**
138    * Assignment operator.
139    * @param[in] parameters The new font parameters.
140    */
141   FontParameters& operator=( const FontParameters& parameters );
142
143   /**
144    * Retrieves the name of the font's family.
145    * @return The name of the font's family.
146    */
147   const std::string& GetFamilyName() const;
148
149   /**
150    * Retrieves the style of the font.
151    * @return The style of the font.
152    */
153   const std::string& GetStyle() const;
154
155   /**
156    * Retrieves the size of the font.
157    * @return The size of the font in Points.
158    */
159   PointSize GetSize() const;
160
161 private:
162   struct Impl;
163   Impl* mImpl; ///< Internal implementation. Not intended for application developers.
164
165 };
166
167 extern FontParameters DEFAULT_FONT_PARAMETERS;
168
169 } // namespace Dali
170
171 /**
172  * @}
173  */
174 #endif // __DALI_FONT_PARAMETERS_H__