1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__
5 * Copyright (c) 2016 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/text-controller.h>
36 const Scripting::StringEnum FONT_WEIGHT_STRING_TABLE[] =
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 }
57 const unsigned int FONT_WEIGHT_STRING_TABLE_COUNT = sizeof( FONT_WEIGHT_STRING_TABLE ) / sizeof( FONT_WEIGHT_STRING_TABLE[0] );
59 const Scripting::StringEnum FONT_WIDTH_STRING_TABLE[] =
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 },
71 const unsigned int FONT_WIDTH_STRING_TABLE_COUNT = sizeof( FONT_WIDTH_STRING_TABLE ) / sizeof( FONT_WIDTH_STRING_TABLE[0] );
73 const Scripting::StringEnum FONT_SLANT_STRING_TABLE[] =
75 { "normal", TextAbstraction::FontSlant::NORMAL },
76 { "roman", TextAbstraction::FontSlant::ROMAN },
77 { "italic", TextAbstraction::FontSlant::ITALIC },
78 { "oblique", TextAbstraction::FontSlant::OBLIQUE }
80 const unsigned int FONT_SLANT_STRING_TABLE_COUNT = sizeof( FONT_SLANT_STRING_TABLE ) / sizeof( FONT_SLANT_STRING_TABLE[0] );
86 DEFAULT, ///< The default font's style.
87 INPUT, ///< The input font's style.
88 PLACEHOLDER ///< The placeholder text font's style.
93 * @brief Sets the font family property.
95 * @param[in] controller The text's controller.
96 * @param[in] value The value of the font's family.
98 void SetFontFamilyProperty( ControllerPtr controller, const Property::Value& value );
101 * @brief Sets the font's style property.
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.
108 void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value, FontStyle::Type type );
111 * @brief Retrieves the font's style property.
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.
117 void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type );
120 * @brief Converts a weight string into @e FontWeight.
122 * @param[in] weightStr The weight string. Must end with '\0'.
124 * @return The @e FontWeight value corresponding to the string.
126 FontWeight StringToWeight( const char* const weightStr );
129 * @brief Converts a width string into @e FontWidth.
131 * @param[in] widthStr The width string. Must end with '\0'.
133 * @return The @e FontWidth value corresponding to the string.
135 FontWidth StringToWidth( const char* const widthStr );
138 * @brief Converts a slant string into @e FontSlant.
140 * @param[in] slantStr The slant string. Must end with '\0'.
142 * @return The @e FontSlant value corresponding to the string.
144 FontSlant StringToSlant( const char* const slantStr );
147 } // namespace Toolkit
151 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H__