Merge "Convert the Underline and Shadow deprecated APIs to the new ones." into devel...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-font-style.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__
3
4 /*
5  * Copyright (c) 2016 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/scripting/scripting.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/text-controller.h>
26 #include <dali-toolkit/internal/text/text-definitions.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Text
35 {
36
37 const Scripting::StringEnum FONT_WEIGHT_STRING_TABLE[] =
38 {
39   { "thin", TextAbstraction::FontWeight::THIN },
40   { "ultraLight", TextAbstraction::FontWeight::ULTRA_LIGHT },
41   { "extraLight", TextAbstraction::FontWeight::EXTRA_LIGHT },
42   { "light", TextAbstraction::FontWeight::LIGHT },
43   { "demiLight", TextAbstraction::FontWeight::DEMI_LIGHT },
44   { "semiLight", TextAbstraction::FontWeight::SEMI_LIGHT },
45   { "book", TextAbstraction::FontWeight::BOOK },
46   { "normal", TextAbstraction::FontWeight::NORMAL },
47   { "regular", TextAbstraction::FontWeight::REGULAR },
48   { "medium", TextAbstraction::FontWeight::MEDIUM },
49   { "demiBold", TextAbstraction::FontWeight::DEMI_BOLD },
50   { "semiBold", TextAbstraction::FontWeight::SEMI_BOLD },
51   { "bold", TextAbstraction::FontWeight::BOLD },
52   { "ultraBold", TextAbstraction::FontWeight::ULTRA_BOLD },
53   { "extraBold", TextAbstraction::FontWeight::EXTRA_BOLD },
54   { "black", TextAbstraction::FontWeight::BLACK },
55   { "heavy", TextAbstraction::FontWeight::HEAVY },
56   { "extraBlack", TextAbstraction::FontWeight::EXTRA_BLACK }
57 };
58 const unsigned int FONT_WEIGHT_STRING_TABLE_COUNT = sizeof( FONT_WEIGHT_STRING_TABLE ) / sizeof( FONT_WEIGHT_STRING_TABLE[0] );
59
60 const Scripting::StringEnum FONT_WIDTH_STRING_TABLE[] =
61 {
62   { "ultraCondensed", TextAbstraction::FontWidth::ULTRA_CONDENSED },
63   { "extraCondensed", TextAbstraction::FontWidth::EXTRA_CONDENSED },
64   { "condensed", TextAbstraction::FontWidth::CONDENSED },
65   { "semiCondensed", TextAbstraction::FontWidth::SEMI_CONDENSED },
66   { "normal", TextAbstraction::FontWidth::NORMAL },
67   { "semiExpanded", TextAbstraction::FontWidth::SEMI_EXPANDED },
68   { "expanded", TextAbstraction::FontWidth::EXPANDED },
69   { "extraExpanded", TextAbstraction::FontWidth::EXTRA_EXPANDED },
70   { "ultraExpanded", TextAbstraction::FontWidth::ULTRA_EXPANDED },
71 };
72 const unsigned int FONT_WIDTH_STRING_TABLE_COUNT = sizeof( FONT_WIDTH_STRING_TABLE ) / sizeof( FONT_WIDTH_STRING_TABLE[0] );
73
74 const Scripting::StringEnum FONT_SLANT_STRING_TABLE[] =
75 {
76   { "normal", TextAbstraction::FontSlant::NORMAL },
77   { "roman", TextAbstraction::FontSlant::ROMAN },
78   { "italic", TextAbstraction::FontSlant::ITALIC },
79   { "oblique", TextAbstraction::FontSlant::OBLIQUE }
80 };
81 const unsigned int FONT_SLANT_STRING_TABLE_COUNT = sizeof( FONT_SLANT_STRING_TABLE ) / sizeof( FONT_SLANT_STRING_TABLE[0] );
82
83 namespace FontStyle
84 {
85   enum Type
86   {
87     DEFAULT, ///< The default font's style.
88     INPUT    ///< The input font's style.
89   };
90 };
91
92 /**
93  * @brief Sets the font's style property.
94  *
95  * @param[in] controller The text's controller.
96  * @param[in] value The value of the font's style.
97  * @param[in] type Whether the property is for the default font's style or the input font's style.
98  *
99  */
100 void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value, FontStyle::Type type );
101
102 /**
103  * @brief Retrieves the font's style property.
104  *
105  * @param[in] controller The text's controller.
106  * @param[out] value The value of the font's style.
107  * @param[in] type Whether the property is for the default font's style or the input font's style.
108  */
109 void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type );
110
111 /**
112  * @brief Converts a weight string into @e FontWeight.
113  *
114  * @param[in] weightStr The weight string. Must end with '\0'.
115  *
116  * @return The @e FontWeight value corresponding to the string.
117  */
118 FontWeight StringToWeight( const char* const weightStr );
119
120 /**
121  * @brief Converts a width string into @e FontWidth.
122  *
123  * @param[in] widthStr The width string. Must end with '\0'.
124  *
125  * @return The @e FontWidth value corresponding to the string.
126  */
127 FontWidth StringToWidth( const char* const widthStr );
128
129 /**
130  * @brief Converts a slant string into @e FontSlant.
131  *
132  * @param[in] slantStr The slant string. Must end with '\0'.
133  *
134  * @return The @e FontSlant value corresponding to the string.
135  */
136 FontSlant StringToSlant( const char* const slantStr );
137 } // namespace Text
138
139 } // namespace Toolkit
140
141 } // namespace Dali
142
143 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__