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 class ParagraphStyle { 35 public: 36 TextStyle ConvertToTextStyle() const; 37 TextAlign GetEquivalentAlign() const; 38 39 FontWeight fontWeight = FontWeight::W400; 40 FontStyle fontStyle = FontStyle::NORMAL; 41 WordBreakType wordBreakType = WordBreakType::NORMAL; 42 std::string fontFamily; 43 double fontSize = 16; 44 double height = 1; 45 bool heightOverride = false; 46 TextHeightBehavior textHeightBehavior = TextHeightBehavior::ALL; 47 48 bool strutEnabled = false; 49 FontWeight strutFontWeight = FontWeight::W400; 50 FontStyle strutFontStyle = FontStyle::NORMAL; 51 std::vector<std::string> strutFontFamilies; 52 double strutFontSize = 16; 53 double strutHeight = 1; 54 bool strutHeightOverride = false; 55 bool strutHalfLeading = false; 56 double strutLeading = -1; 57 bool forceStrutHeight = false; 58 TextAlign textAlign = TextAlign::START; 59 TextDirection textDirection = TextDirection::LTR; 60 EllipsisModal ellipsisModal = EllipsisModal::TAIL; 61 size_t maxLines = std::numeric_limits<size_t>::max(); 62 std::u16string ellipsis = u"\u2026"; 63 std::string locale; 64 float textSplitRatio = 0.5; 65 bool textOverflower = false; 66 }; 67 } // namespace SPText 68 } // namespace Rosen 69 } // namespace OHOS 70 71 #endif // ROSEN_MODULES_SPTEXT_PARAGRAPH_STYLE_H 72