1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ROSEN_MODULES_TEXGINE_EXPORT_TEXGINE_TYPOGRAPHY_TYPES_H
17 #define ROSEN_MODULES_TEXGINE_EXPORT_TEXGINE_TYPOGRAPHY_TYPES_H
18 
19 #include <memory>
20 #include <optional>
21 #include <vector>
22 
23 #include "texgine/font_providers.h"
24 #include "texgine_paint.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 namespace TextEngine {
29 /*
30  * @brief BreakStrategy is a strategy on how to wrap when
31  *        there are multiple lines of text.
32  */
33 enum class BreakStrategy {
34     GREEDY,                  // this strategy wraps lines when they have to.
35     HIGH_QUALITY,            // this strategy aims to make the line-wrapped result
36                              // look as neat as possible, not jagged.
37     BALANCED = HIGH_QUALITY, // to be done.
38 };
39 
40 /*
41  * @brief FontStyle is font italic style.
42  */
43 enum class FontStyle {
44     NORMAL,
45     ITALIC,
46     MAX,
47 };
48 
49 /*
50  * @brief FontWeight is font weight style.
51  */
52 enum class FontWeight {
53     W100 = 0, // weight value 100 thin.
54     W200 = 1, // weight value 200.
55     W300 = 2, // weight value 300.
56     W400 = 3, // weight value 400 normal.
57     W500 = 4, // weight value 500.
58     W600 = 5, // weight value 600.
59     W700 = 6, // weight value 700 bold.
60     W800 = 7, // weight value 800.
61     W900 = 8, // weight value 900.
62     MAX,      // use for check.
63 };
64 
65 /*
66  * @brief TextAlign is text alignment style.
67  *        The bit field has an alignment style and trim style.
68  */
69 enum class TextAlign {
70     DEFAULT = 0,   // alias for Start.
71     START = 1,     // LTR: align left, RTL: align right.
72     END = 2,       // LTR: align right, RTL: align left.
73     LEFT = 3,      // align left.
74     RIGHT = 4,     // align right.
75     CENTER = 5,    // center alignment.
76     JUSTIFY = 6,   // justified alignment.
77     SCATTERED = 7, // scatter alignment.
78 
79     // trim part
80     TRIM = 0x8,    // when trim is enabled, whitespace is not considered.
81     STARTTRIM = START | TRIM,
82     ENDTRIM = END | TRIM,
83     LEFTTRIM = LEFT | TRIM,
84     RIGHTTRIM = RIGHT | TRIM,
85     CENTERTRIM = CENTER | TRIM,
86     JUSTIFYTRIM = JUSTIFY | TRIM,
87     SCATTEREDTRIM = SCATTERED | TRIM,
88 };
89 TextAlign operator |(TextAlign lhs, TextAlign rhs);
90 TextAlign operator &(TextAlign lhs, TextAlign rhs);
91 TextAlign operator ^(TextAlign lhs, TextAlign rhs);
92 TextAlign operator ~(TextAlign lhs);
93 void operator &=(TextAlign &lhs, const TextAlign &rhs);
94 void operator |=(TextAlign &lhs, const TextAlign &rhs);
95 void operator ^=(TextAlign &lhs, const TextAlign &rhs);
96 
97 /*
98  * @brief TextBaseline is text baseline style.
99  */
100 enum class TextBaseline {
101     ALPHABETIC,
102     IDEOGRAPHIC,
103 };
104 
105 /*
106  * @brief TextDecoration is text decoration style.
107  *        Use bit fields for storage.
108  */
109 enum class TextDecoration : int {
110     NONE = 0x0,
111     UNDERLINE = 0x1,
112     OVERLINE = 0x2,
113     LINE_THROUGH = 0x4,
114     BASELINE = 0x8,
115 };
116 TextDecoration operator &(TextDecoration const &lhs, TextDecoration const &rhs);
117 TextDecoration operator |(TextDecoration const &lhs, TextDecoration const &rhs);
118 TextDecoration operator ^(TextDecoration const &lhs, TextDecoration const &rhs);
119 TextDecoration operator +(TextDecoration const &lhs, TextDecoration const &rhs);
120 void operator &=(TextDecoration &lhs, TextDecoration const &rhs);
121 void operator |=(TextDecoration &lhs, TextDecoration const &rhs);
122 void operator ^=(TextDecoration &lhs, TextDecoration const &rhs);
123 void operator +=(TextDecoration &lhs, TextDecoration const &rhs);
124 
125 /*
126  * @brief TextDecorationStyle is decoration line style.
127  */
128 enum class TextDecorationStyle {
129     SOLID,
130     DOUBLE,
131     DOTTED,
132     DASHED,
133     WAVY,
134 };
135 
136 /*
137  * @brief TextDirection is text direction style.
138  */
139 enum class TextDirection {
140     LTR, // left to right
141     RTL, // right to left
142 };
143 
144 /*
145  * @brief WordBreakType is the type of word break when multiline text wraps.
146  */
147 enum class WordBreakType {
148     NORMAL,     // to be done.
149     BREAK_ALL,  // break occur after any characters.
150     BREAK_WORD, // break only occur after word.
151 };
152 
153 /*
154  * @brief EllipsisModal is the pattern of ellipsis.
155  */
156 enum class EllipsisModal {
157     HEAD = 0,
158     MIDDLE = 1,
159     TAIL = 2,
160 };
161 } // namespace TextEngine
162 } // namespace Rosen
163 } // namespace OHOS
164 
165 #endif // ROSEN_MODULES_TEXGINE_EXPORT_TEXGINE_TYPOGRAPHY_TYPES_H
166