Merge "Added code for stylable transitions" 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   };
89 };
90
91 /**
92  * @brief Sets the font family property.
93  *
94  * @param[in] controller The text's controller.
95  * @param[in] value The value of the font's family.
96  */
97 void SetFontFamilyProperty( ControllerPtr controller, const Property::Value& value );
98
99 /**
100  * @brief Sets the font's style property.
101  *
102  * @param[in] controller The text's controller.
103  * @param[in] value The value of the font's style.
104  * @param[in] type Whether the property is for the default font's style or the input font's style.
105  *
106  */
107 void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value, FontStyle::Type type );
108
109 /**
110  * @brief Retrieves the font's style property.
111  *
112  * @param[in] controller The text's controller.
113  * @param[out] value The value of the font's style.
114  * @param[in] type Whether the property is for the default font's style or the input font's style.
115  */
116 void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type );
117
118 /**
119  * @brief Converts a weight string into @e FontWeight.
120  *
121  * @param[in] weightStr The weight string. Must end with '\0'.
122  *
123  * @return The @e FontWeight value corresponding to the string.
124  */
125 FontWeight StringToWeight( const char* const weightStr );
126
127 /**
128  * @brief Converts a width string into @e FontWidth.
129  *
130  * @param[in] widthStr The width string. Must end with '\0'.
131  *
132  * @return The @e FontWidth value corresponding to the string.
133  */
134 FontWidth StringToWidth( const char* const widthStr );
135
136 /**
137  * @brief Converts a slant string into @e FontSlant.
138  *
139  * @param[in] slantStr The slant string. Must end with '\0'.
140  *
141  * @return The @e FontSlant value corresponding to the string.
142  */
143 FontSlant StringToSlant( const char* const slantStr );
144 } // namespace Text
145
146 } // namespace Toolkit
147
148 } // namespace Dali
149
150 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__