1 /* 2 * Copyright (c) 2022 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 #include "rosen_text/properties/typography_style.h" 17 18 namespace rosen { 19 const std::u16string TypographyStyle::ELLIPSIS = u"\u2026"; 20 GetTextStyle() const21TextStyle TypographyStyle::GetTextStyle() const 22 { 23 TextStyle textstyle; 24 textstyle.fontWeight_ = fontWeight_; 25 textstyle.fontStyle_ = fontStyle_; 26 textstyle.fontFamilies_ = std::vector<std::string>({fontFamily_}); 27 if (fontSize_ >= 0) { 28 textstyle.fontSize_ = fontSize_; 29 } 30 textstyle.locale_ = locale_; 31 textstyle.height_ = height_; 32 textstyle.hasHeightOverride_ = hasHeightOverride_; 33 if (Ellipsized()) { 34 textstyle.ellipsis_ = ellipsis_; 35 } 36 return textstyle; 37 } 38 EffectiveAlign() const39TextAlign TypographyStyle::EffectiveAlign() const 40 { 41 if (textAlign_ == TextAlign::START) { 42 return (textDirection_ == TextDirection::LTR) ? TextAlign::LEFT 43 : TextAlign::RIGHT; 44 } else if (textAlign_ == TextAlign::END) { 45 return (textDirection_ == TextDirection::LTR) ? TextAlign::RIGHT 46 : TextAlign::LEFT; 47 } else { 48 return textAlign_; 49 } 50 } 51 } // namespace rosen 52