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