1 /* 2 * Copyright (c) 2024 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_MODULES_SPTEXT_PARAGRAPH_STYLE_H 17 #define ROSEN_MODULES_SPTEXT_PARAGRAPH_STYLE_H 18 19 #include <climits> 20 #include <string> 21 22 #include "text_style.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 namespace SPText { 27 28 enum class WordBreakType { 29 NORMAL, // to be done. 30 BREAK_ALL, // break occur after any characters. 31 BREAK_WORD, // break only occur after word. 32 }; 33 34 enum class BreakStrategy { 35 GREEDY = 0, 36 HIGH_QUALITY = 1, 37 BALANCED = 2 38 }; 39 40 class ParagraphStyle { 41 public: 42 TextStyle ConvertToTextStyle() const; 43 TextAlign GetEquivalentAlign() const; 44 45 FontWeight fontWeight = FontWeight::W400; 46 FontWidth fontWidth = FontWidth::NORMAL; 47 FontStyle fontStyle = FontStyle::NORMAL; 48 WordBreakType wordBreakType = WordBreakType::NORMAL; 49 std::string fontFamily; 50 double fontSize = 16; 51 double height = 1; 52 bool heightOverride = false; 53 54 bool strutEnabled = false; 55 FontWeight strutFontWeight = FontWeight::W400; 56 FontWidth strutFontWidth = FontWidth::NORMAL; 57 FontStyle strutFontStyle = FontStyle::NORMAL; 58 std::vector<std::string> strutFontFamilies; 59 double strutFontSize = 16; 60 double strutHeight = 1; 61 bool strutHeightOverride = false; 62 bool strutHalfLeading = false; 63 double strutLeading = -1; 64 bool forceStrutHeight = false; 65 TextAlign textAlign = TextAlign::START; 66 TextDirection textDirection = TextDirection::LTR; 67 EllipsisModal ellipsisModal = EllipsisModal::TAIL; 68 size_t maxLines = std::numeric_limits<size_t>::max(); 69 std::u16string ellipsis = u"\u2026"; 70 std::string locale; 71 float textSplitRatio = 0.5; 72 bool textOverflower = false; 73 TextStyle spTextStyle; 74 bool customSpTextStyle = false; 75 TextHeightBehavior textHeightBehavior = TextHeightBehavior::ALL; 76 bool hintingIsOn = false; 77 BreakStrategy breakStrategy = BreakStrategy::GREEDY; 78 }; 79 } // namespace SPText 80 } // namespace Rosen 81 } // namespace OHOS 82 83 #endif // ROSEN_MODULES_SPTEXT_PARAGRAPH_STYLE_H 84