1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H
5 * Copyright (c) 2022 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 #include <dali/devel-api/scripting/scripting.h>
25 #include <dali-toolkit/internal/text/controller/text-controller.h>
33 const Scripting::StringEnum FONT_WEIGHT_STRING_TABLE[] =
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]);
55 const Scripting::StringEnum FONT_WIDTH_STRING_TABLE[] =
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},
67 const unsigned int FONT_WIDTH_STRING_TABLE_COUNT = sizeof(FONT_WIDTH_STRING_TABLE) / sizeof(FONT_WIDTH_STRING_TABLE[0]);
69 const Scripting::StringEnum FONT_SLANT_STRING_TABLE[] =
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]);
81 DEFAULT, ///< The default font's style.
82 INPUT, ///< The input font's style.
83 PLACEHOLDER ///< The placeholder text font's style.
88 * @brief Sets the font family property.
90 * @param[in] controller The text's controller.
91 * @param[in] value The value of the font's family.
93 void SetFontFamilyProperty(ControllerPtr controller, const Property::Value& value);
96 * @brief Sets the font's style property.
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.
103 void SetFontStyleProperty(ControllerPtr controller, const Property::Value& value, FontStyle::Type type);
106 * @brief Retrieves the font's style property.
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.
112 void GetFontStyleProperty(ControllerPtr controller, Property::Value& value, FontStyle::Type type);
115 * @brief Converts a weight string into @e FontWeight.
117 * @param[in] weightStr The weight string. Must end with '\0'.
119 * @return The @e FontWeight value corresponding to the string.
121 FontWeight StringToWeight(const char* const weightStr);
124 * @brief Converts a width string into @e FontWidth.
126 * @param[in] widthStr The width string. Must end with '\0'.
128 * @return The @e FontWidth value corresponding to the string.
130 FontWidth StringToWidth(const char* const widthStr);
133 * @brief Converts a slant string into @e FontSlant.
135 * @param[in] slantStr The slant string. Must end with '\0'.
137 * @return The @e FontSlant value corresponding to the string.
139 FontSlant StringToSlant(const char* const slantStr);
142 } // namespace Toolkit
146 #endif // DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H