1 #ifndef __DALI_TEXT_STYLE_H__
2 #define __DALI_TEXT_STYLE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @addtogroup CAPI_DALI_TEXT_MODULE
30 #include <dali/public-api/text/font.h>
32 namespace Dali DALI_IMPORT_API
36 * @brief Encapsulates style properties for text, such as weight, italics, underline, shadow, etc.
42 * @brief Mask used to set text styles.
46 FONT = 1 << 0, ///< Sets the given font family.
47 STYLE = 1 << 1, ///< Sets the given font style.
48 SIZE = 1 << 2, ///< Sets the given font point size.
49 WEIGHT = 1 << 3, ///< Sets the given font weight to bold.
50 COLOR = 1 << 4, ///< Sets the given text color.
51 ITALICS = 1 << 5, ///< Sets italics.
52 UNDERLINE = 1 << 6, ///< Sets underline.
53 SHADOW = 1 << 7, ///< Sets shadow.
54 GLOW = 1 << 8, ///< Sets glow.
55 OUTLINE = 1 << 9, ///< Sets outline
56 ALL = -1 ///< Sets all given style parameters.
60 * @brief Enumeration of various text weights.
78 static const Degree DEFAULT_ITALICS_ANGLE; ///< Default angle used for text italics. @see SetItalics()
79 static const float DEFAULT_UNDERLINE_THICKNESS; ///< Default underline's thickness.
80 static const float DEFAULT_UNDERLINE_POSITION; ///< Default underline's position.
81 static const Vector4 DEFAULT_TEXT_COLOR; ///< Default color for the text (white)
82 static const Vector4 DEFAULT_SHADOW_COLOR; ///< Default color for the shadow (black)
83 static const Vector2 DEFAULT_SHADOW_OFFSET; ///< Default offset used for text shadow. @see SetShadow()
84 static const float DEFAULT_SHADOW_SIZE; ///< Default size of text shadow. @see SetShadow()
85 static const Vector4 DEFAULT_GLOW_COLOR; ///< Default color for the glow (white)
86 static const float DEFAULT_GLOW_INTENSITY; ///< Default intensity used for text glow. @see SetGlow()
87 static const float DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; ///< Default distance field used for edge smooth. @see SetSmoothEdge()
88 static const Vector4 DEFAULT_OUTLINE_COLOR; ///< Default color for the outline (white)
89 static const Vector2 DEFAULT_OUTLINE_THICKNESS; ///< Default thickness used for text outline. @see SetOutline()
90 static const Vector4 DEFAULT_GRADIENT_COLOR; ///< Default gradient color
91 static const Vector2 DEFAULT_GRADIENT_START_POINT; ///< Default gradient start point
92 static const Vector2 DEFAULT_GRADIENT_END_POINT; ///< Default gradient end point
97 * @brief Default constructor.
99 * The style created used a default font @see Dali::Font, color is white, and is neither underlined nor italics.
104 * @brief Copy constructor.
106 * @param[in] textStyle The text style to be copied.
108 TextStyle( const TextStyle& textStyle );
113 virtual ~TextStyle();
116 * @brief Assignment operator.
118 * @param[in] textStyle The text style to be assigned.
119 * @return A reference to this
121 TextStyle& operator=( const TextStyle& textStyle );
124 * @brief Equality operator.
126 * @param [in] textStyle The text style to be compared.
127 * @return true if the style is identical
129 bool operator==( const TextStyle& textStyle ) const;
132 * @brief Inequality operator.
134 * @param [in] textStyle The text style to be compared.
135 * @return true if the text style is not identical
137 bool operator!=( const TextStyle& textStyle ) const;
140 * @brief Copies from the given text style those parameters specified in the given mask.
143 * @param[in] textStyle The given text style.
144 * @param[in] mask Specifies which text style parameters are going to be copied. By default all parateres are copied.
146 void Copy( const TextStyle& textStyle, const Mask mask = ALL );
149 * @brief Retrieves the font name.
151 * @return The font name.
153 const std::string& GetFontName() const;
156 * @brief Sets the font name.
158 * @param[in] fontName
160 void SetFontName( const std::string& fontName );
163 * @brief Retrieves the font style.
165 * @return The font style.
167 const std::string& GetFontStyle() const;
170 * @brief Sets the font style.
172 * @param[in] fontStyle
174 void SetFontStyle( const std::string& fontStyle );
177 * @brief Retrieves the font point size.
179 * @return the point size.
181 PointSize GetFontPointSize() const;
184 * @brief Sets the font point size.
186 * @param[in] fontPointSize The font point size.
188 void SetFontPointSize( PointSize fontPointSize );
191 * @brief Retrieves the style weight.
193 * @return The style weight.
195 Weight GetWeight() const;
198 * @brief Sets the style weight.
200 * @param[in] weight The style weight
202 void SetWeight( Weight weight );
205 * @brief Retrieves the text color.
207 * @return The text color.
209 const Vector4& GetTextColor() const;
212 * @brief Sets the text color.
214 * @param[in] textColor The text color
216 void SetTextColor( const Vector4& textColor );
219 * @brief Whether the style italics option is enabled or not.
221 * @return \e true if italics is enabled.
223 bool GetItalics() const;
226 * @brief Sets the italics option.
228 * @param[in] italics The italics option.
230 void SetItalics( bool italics );
233 * @brief Retrieves the italics angle.
235 * @return \e The italics angle in degree.
237 Degree GetItalicsAngle() const;
240 * @brief Sets the italics angle.
242 * @param[in] angle The italics angle in degree.
244 void SetItalicsAngle( Degree angle );
247 * @brief Whether the style underline option is enabled or not.
249 * @return \e true if underline is enabled.
251 bool GetUnderline() const;
254 * @brief Sets the underline option.
256 * @param[in] underline The underline option.
258 void SetUnderline( bool underline );
261 * @brief Retrieves the underline thickness.
263 * @return The underline thickness.
265 float GetUnderlineThickness() const;
268 * @brief Sets the underline thickness.
270 * @param[in] thickness The underline thickness.
272 void SetUnderlineThickness( float thickness );
275 * @brief Retrieves the underline position.
277 * @return The underline position.
279 float GetUnderlinePosition() const;
282 * @brief Sets the underline position.
284 * @param[in] position The underline position.
286 void SetUnderlinePosition( float position );
289 * @brief Whether the style shadow option is enabled or not.
291 * @return \e true if shadow is enabled.
293 bool GetShadow() const;
296 * @brief Retrieves the shadow color.
298 * @return The shadow color.
300 const Vector4& GetShadowColor() const;
303 * @brief Retrieves the shadow offset
304 * @return The shadow offset.
307 const Vector2& GetShadowOffset() const;
310 * @brief Retrieves the shadow size
311 * @return The shadow size.
314 float GetShadowSize() const;
317 * @brief Sets the shadow option.
319 * @param[in] shadow The shadow option.
320 * @param[in] shadowColor The color of the shadow
321 * @param[in] shadowOffset Offset in pixels.
322 * @param[in] shadowSize Size of shadow in pixels. 0 means the shadow is the same size as the text.
324 void SetShadow( bool shadow,
325 const Vector4& shadowColor = DEFAULT_SHADOW_COLOR,
326 const Vector2& shadowOffset = DEFAULT_SHADOW_OFFSET,
327 const float shadowSize = DEFAULT_SHADOW_SIZE );
330 * @brief Whether the glow option is enabled or not.
332 * @return \e true if glow is enabled.
334 bool GetGlow() const;
337 * @brief Retrieves the glow color.
339 * @return The glow color.
341 const Vector4& GetGlowColor() const;
344 * @brief Retrieve the glow intensity.
346 * @return The glow intensity.
348 float GetGlowIntensity() const;
351 * @brief Sets the glow option and color.
353 * @param[in] glow The glow option.
354 * @param[in] glowColor The color of the glow.
355 * @param[in] glowIntensity Determines the amount of glow around text.
356 * The edge of the text is at the value set with smoothEdge.
357 * SetSmoothEdge() The distance field value at which the glow becomes fully transparent.
359 void SetGlow( bool glow, const Vector4& glowColor = DEFAULT_GLOW_COLOR, float glowIntensity = DEFAULT_GLOW_INTENSITY );
362 * @brief Retrieves the soft smooth edge.
364 * @return The soft smooth edge.
366 float GetSmoothEdge() const;
369 * @brief Set soft edge smoothing.
371 * @param[in] smoothEdge Specify the distance field value for the center of the text edge.
372 * 0 <= smoothEdge <= 1
374 void SetSmoothEdge( float smoothEdge = DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD );
377 * @brief Whether the outline option is enabled or not.
379 * @return \e true if outline is enabled.
381 bool GetOutline() const;
384 * @brief Retrieves the outline color.
386 * @return The outline color.
388 const Vector4& GetOutlineColor() const;
391 * @brief Retrieves the outline thickness.
393 * @return The outline thickness.
395 const Vector2& GetOutlineThickness() const;
398 * @brief Sets the outline option and color.
400 * @param[in] outline The outline option.
401 * @param[in] outlineColor The color of the outline.
402 * @param[in] outlineThickness Thickness of outline. The outline thickness is determined by two parameters.
403 * outlineThickness[0] Specifies the distance field value for the center of the outline.
404 * outlineThickness[1] Specifies the softness/width/anti-aliasing of the outlines inner edge.
405 * SetSmoothEdge() specifies the smoothness/anti-aliasing of the text outer edge.
406 * 0 <= smoothEdge[0] <= 1.
407 * 0 <= smoothEdge[1] <= 1.
409 void SetOutline( bool outline, const Vector4& outlineColor = DEFAULT_OUTLINE_COLOR, const Vector2& outlineThickness = DEFAULT_OUTLINE_THICKNESS );
413 Impl* mImpl; ///< Implementation pointer
416 * @brief Creates A TextStyle::Impl object when needed
418 void CreateImplementationJustInTime();
427 #endif // __DALI_TEXT_STYLE_H__