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