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