Merge branch 'tizen' into new_text
[platform/core/uifw/dali-core.git] / 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 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/public-api/object/base-handle.h>
23 #include <dali/public-api/text/text.h>
24
25 namespace Dali
26 {
27
28 /**
29  * @brief Font size in points.
30  *
31  * This reduces ambiguity when using methods which accept size in pixels or points.
32  */
33 struct DALI_IMPORT_API PointSize
34 {
35   /**
36    * @brief Create size in points.
37    *
38    * @param[in] value The value in points.
39    */
40   explicit PointSize(float value);
41
42   /**
43    * @brief Float cast operator.
44    */
45   operator float() const;
46
47   /**
48    * @brief Equality operator.
49    *
50    * @param pointSize The point size to be compared.
51    * @return \e true if \e pointSize is equal to the point size stored in this object.
52    */
53   bool operator==( PointSize pointSize );
54
55   /**
56    * @brief Inequality operator.
57    *
58    * @param pointSize The point size to be compared.
59    * @return \e true if \e pointSize is not equal to the point size stored in this object.
60    */
61   bool operator!=( PointSize pointSize );
62
63   float value; ///< The value in points
64 };
65
66 /**
67  * @brief Font size in pixels.
68  *
69  * This reduces ambiguity when using methods which accept size in pixels or points.
70  */
71 struct DALI_IMPORT_API PixelSize
72 {
73   /**
74    * @brief Create size in pixels.
75    *
76    * @param[in] value The value in pixels.
77    */
78   explicit PixelSize(unsigned int value);
79
80   /**
81    * @brief Cast operator
82    */
83   operator unsigned int() const;
84
85   unsigned int value; ///< The value in pixels
86 };
87
88 /**
89  * @brief Font size in Caps height
90  */
91 struct DALI_IMPORT_API CapsHeight
92 {
93   /**
94    * @brief Size in CapsHeight
95    */
96   explicit CapsHeight( unsigned int value);
97
98   /**
99    * @brief Cast operator
100    */
101   operator unsigned int() const;
102
103   unsigned int value; ///< The value in pixels
104 };
105
106 /**
107  * @brief Encapsulates all font parameters.
108  */
109 struct DALI_IMPORT_API FontParameters
110 {
111   /**
112    * @brief Default constructor.
113    *
114    * Default system font family name, default system font style and default system size
115    * will be used to build the font.
116    */
117   FontParameters();
118
119   /**
120    * @brief Constructor.
121    *
122    * Creates font parameters with the given family's name, style and size in points from the font requested.
123    * @param[in] familyName The family's name of the font requested.
124    * @param[in] style The style of the font requested.
125    * @param[in] size The size of the font requested in points.
126    */
127   FontParameters( const std::string& familyName, const std::string& style, PointSize size );
128
129   /**
130    * @brief Constructor.
131    *
132    * Creates font parameters with the given family's name, style and size in pixels from the font requested.
133    * @param[in] familyName The family's name of the font requested.
134    * @param[in] style The style of the font requested.
135    * @param[in] size The size of the font requested in pixels.
136    */
137   FontParameters( const std::string& familyName, const std::string& style, PixelSize size );
138
139   /**
140    * @brief Constructor.
141    *
142    * Creates font parameters with the given family's name, style and the caps-height size in pixels from the font requested.
143    * @param[in] familyName The family's name of the font requested.
144    * @param[in] style The style of the font requested.
145    * @param[in] size The caps-height of the font requested in pixels.
146    */
147   FontParameters( const std::string& familyName, const std::string& style, CapsHeight size );
148
149   /**
150    * @brief Destructor.
151    *
152    * Destroys the internal implementation.
153    */
154   ~FontParameters();
155
156   /**
157    * @brief Copy constructor.
158    *
159    * Reset the internal implementation with new given values.
160    * @param[in] parameters The new font parameters.
161    */
162   FontParameters( const FontParameters& parameters );
163
164   /**
165    * @brief Assignment operator.
166    *
167    * @param[in] parameters The new font parameters.
168    * @return A reference to this
169    */
170   FontParameters& operator=( const FontParameters& parameters );
171
172   /**
173    * @brief Retrieves the name of the font's family.
174    *
175    * @return The name of the font's family.
176    */
177   const std::string& GetFamilyName() const;
178
179   /**
180    * @brief Retrieves the style of the font.
181    *
182    * @return The style of the font.
183    */
184   const std::string& GetStyle() const;
185
186   /**
187    * @brief Retrieves the size of the font.
188    *
189    * @return The size of the font in Points.
190    */
191   PointSize GetSize() const;
192
193 private:
194   struct Impl;
195   Impl* mImpl; ///< Internal implementation. Not intended for application developers.
196
197 };
198
199 DALI_IMPORT_API extern FontParameters DEFAULT_FONT_PARAMETERS; ///< Used to choose the platform's font parameters
200
201 } // namespace Dali
202
203 #endif // __DALI_FONT_PARAMETERS_H__