Merge "Spannable: Add FontSpan" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / text / spans / font-span.h
1 #ifndef DALI_TOOLKIT_TEXT_FONT_SPAN_H
2 #define DALI_TOOLKIT_TEXT_FONT_SPAN_H
3
4 /*
5  * Copyright (c) 2022 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/devel-api/text-abstraction/font-list.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/devel-api/text/spans/base-span.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 namespace Internal DALI_INTERNAL
34 {
35 class FontSpan;
36 }
37
38 /**
39  * @brief FontSpan is a handle to an object that specifies the font properties for range of characters.
40  */
41 class DALI_TOOLKIT_API FontSpan : public BaseSpan
42 {
43 public:
44   /**
45    * @brief Create an initialized FontSpan.
46    *
47    * @param[in] familyName The font family name.
48    * @param[in] sizeInPoints The font size.
49    * @param[in] weight The font weight.
50    * @param[in] width The font width.
51    * @param[in] slant The font slant.
52    *
53    * @return A handle to a newly allocated Dali resource
54    */
55   static FontSpan New(const std::string                             familyName,
56                       const float                                   sizeInPoints,
57                       const Dali::TextAbstraction::FontWeight::Type weight,
58                       const Dali::TextAbstraction::FontWidth::Type  width,
59                       const Dali::TextAbstraction::FontSlant::Type  slant);
60
61   /**
62    * @brief Creates an uninitialized FontSpan handle.
63    *
64    * Calling member functions with an uninitialized FontSpan handle is not allowed.
65    */
66   FontSpan();
67
68   /**
69    * @brief Copy constructor.
70    * @param[in] rhs A reference to the copied handle
71    */
72   FontSpan(const FontSpan& rhs);
73
74   /**
75    * @brief Move constructor.
76    * @param[in] rhs A reference to the handle to move
77    */
78   FontSpan(FontSpan&& rhs);
79
80   /**
81    * @brief Assignment operator.
82    * @param[in] rhs A reference to the copied handle
83    * @return A reference to this
84    */
85   FontSpan& operator=(const FontSpan& rhs);
86
87   /**
88    * @brief Move assignment operator.
89    * @param[in] rhs A reference to the moved handle
90    * @return A reference to this
91    */
92   FontSpan& operator=(FontSpan&& rhs);
93
94   /**
95    * @brief Non virtual destructor.
96    */
97   ~FontSpan();
98
99   /**
100    * @brief Downcasts to a FontSpan handle.
101    * If handle is not a FontSpan, the returned handle is left uninitialized.
102    *
103    * @param[in] handle Handle to an object
104    * @return FontSpan handle or an uninitialized handle
105    */
106   static FontSpan DownCast(BaseHandle handle);
107
108 public: //Methods
109   /**
110    * @brief Retrive the font family name.
111    *
112    * @return A family name value.
113    */
114   const std::string GetFamilyName() const;
115
116   /**
117    * @brief Retrive the font weight.
118    *
119    * @return A font weight value.
120    */
121   const Dali::TextAbstraction::FontWeight::Type GetWeight() const;
122
123   /**
124    * @brief Retrive the font width.
125    *
126    * @return A font width value.
127    */
128   const Dali::TextAbstraction::FontWidth::Type GetWidth() const;
129
130   /**
131    * @brief Retrive the font slant.
132    *
133    * @return A font slant value.
134    */
135   const Dali::TextAbstraction::FontSlant::Type GetSlant() const;
136
137   /**
138    * @brief Retrive the font size.
139    *
140    * @return A font size value.
141    */
142   const float GetSize() const;
143
144   /**
145    * @brief Retrieve whether the font family name is defined.
146    *
147    * @return The return is true if font family name is defined, otherwise false.
148    */
149   bool IsFamilyNameDefined() const;
150
151   /**
152    * @brief Retrieve whether the font weight is defined.
153    *
154    * @return The return is true if font weight is defined, otherwise false.
155    */
156   bool IsWeightDefined() const;
157
158   /**
159    * @brief Retrieve whether the font width is defined.
160    *
161    * @return The return is true if font width is defined, otherwise false.
162    */
163   bool IsWidthDefined() const;
164
165   /**
166    * @brief Retrieve whether the font slant is defined.
167    *
168    * @return The return is true if font slant is defined, otherwise false.
169    */
170   bool IsSlantDefined() const;
171
172   /**
173    * @brief Retrieve whether the font size is defined.
174    *
175    * @return The return is true if font size is defined, otherwise false.
176    */
177
178   bool IsSizeDefined() const;
179
180 public: // Not intended for application developers
181   /// @cond internal
182   /**
183    * @brief This constructor is used internally to Create an initialized FontSpan handle.
184    *
185    * @param[in] fontSpan Pointer to internal FontSpan
186    */
187   explicit DALI_INTERNAL FontSpan(Internal::FontSpan* fontSpan);
188   /// @endcond
189 };
190
191 } // namespace Text
192
193 } // namespace Toolkit
194
195 } // namespace Dali
196
197 #endif // DALI_TOOLKIT_TEXT_FONT_SPAN_H