1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd.. All rights reserved. 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_TEXT_EXPORT_ROSEN_TEXT_TYPOGRAPHY_TYPES_H 17 #define ROSEN_TEXT_EXPORT_ROSEN_TEXT_TYPOGRAPHY_TYPES_H 18 19 #include <cstddef> 20 21 namespace OHOS { 22 namespace Rosen { 23 enum class TextVerticalAlign { 24 BASELINE = 0, 25 BOTTOM = 1, 26 CENTER = 2, 27 TOP = 3 28 }; 29 30 enum class TextDirection { 31 RTL, 32 LTR, 33 }; 34 35 enum class TextAlign { 36 LEFT, 37 RIGHT, 38 CENTER, 39 JUSTIFY, 40 START, 41 END, 42 }; 43 44 enum class BreakStrategy { 45 GREEDY = 0, 46 HIGH_QUALITY = 1, 47 BALANCED = 2 48 }; 49 50 enum class WordBreakType { 51 NORMAL = 0, 52 BREAK_ALL = 1, 53 BREAK_WORD = 2, 54 BREAK_HYPHEN = 3 55 }; 56 57 enum TextDecoration { 58 NONE = 0x0, 59 UNDERLINE = 0x1, 60 OVERLINE = 0x2, 61 LINE_THROUGH = 0x4, 62 }; 63 64 enum class TextDecorationStyle { 65 SOLID, 66 DOUBLE, 67 DOTTED, 68 DASHED, 69 WAVY, 70 }; 71 72 enum class FontWeight { 73 W100, // thin 74 W200, 75 W300, 76 W400, // normal 77 W500, 78 W600, 79 W700, // bold 80 W800, 81 W900, 82 }; 83 84 enum class FontWidth { 85 ULTRA_CONDENSED = 1, 86 EXTRA_CONDENSED = 2, 87 CONDENSED = 3, 88 SEMI_CONDENSED = 4, 89 NORMAL = 5, 90 SEMI_EXPANDED = 6, 91 EXPANDED = 7, 92 EXTRA_EXPANDED = 8, 93 ULTRA_EXPANDED = 9, 94 }; 95 96 enum class FontStyle { 97 NORMAL, 98 ITALIC, 99 OBLIQUE, 100 }; 101 102 enum class TextBaseline { 103 ALPHABETIC, 104 IDEOGRAPHIC, 105 }; 106 107 enum class EllipsisModal { 108 HEAD = 0, 109 MIDDLE = 1, 110 TAIL = 2, 111 }; 112 113 enum TextHeightBehavior { 114 ALL = 0x0, 115 DISABLE_FIRST_ASCENT = 0x1, 116 DISABLE_LAST_ASCENT = 0x2, 117 DISABLE_ALL = 0x1 | 0x2, 118 }; 119 120 enum StyleType { 121 NONE_ATTRIBUTES, 122 ALL_ATTRIBUTES, 123 FONT, 124 FOREGROUND, 125 BACKGROUND, 126 SHADOW, 127 DECORATIONS, 128 LETTER_SPACING, 129 WORD_SPACING 130 }; 131 132 struct Boundary { 133 size_t leftIndex = 0; // include leftIndex_ 134 size_t rightIndex = 0; // not include rightIndex_ 135 BoundaryBoundary136 Boundary(size_t left, size_t right) 137 { 138 leftIndex = left; 139 rightIndex = right; 140 } 141 142 bool operator ==(const Boundary& rhs) const 143 { 144 return leftIndex == rhs.leftIndex && rightIndex == rhs.rightIndex; 145 } 146 }; 147 148 } // namespace Rosen 149 } // namespace OHOS 150 151 #endif // ROSEN_TEXT_EXPORT_ROSEN_TEXT_TYPOGRAPHY_TYPES_H 152