• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
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 "core/components/common/properties/text_style.h"
17 
18 #include "core/pipeline/base/constants.h"
19 
20 namespace OHOS::Ace {
21 
TextStyle(const std::vector<std::string> & fontFamilies,double fontSize,FontWeight fontWeight,FontStyle fontStyle,const Color & textColor)22 TextStyle::TextStyle(const std::vector<std::string>& fontFamilies, double fontSize, FontWeight fontWeight,
23     FontStyle fontStyle, const Color& textColor)
24     : fontFamilies_(fontFamilies), fontSize_(fontSize), fontWeight_(fontWeight), fontStyle_(fontStyle),
25       textColor_(textColor)
26 {}
27 
operator ==(const TextStyle & rhs) const28 bool TextStyle::operator==(const TextStyle& rhs) const
29 {
30     return fontFamilies_ == rhs.fontFamilies_ && fontFeatures_ == rhs.fontFeatures_ &&
31            preferFontSizes_ == rhs.preferFontSizes_ && fontSize_ == rhs.fontSize_ &&
32            adaptMinFontSize_ == rhs.adaptMinFontSize_ && adaptMaxFontSize_ == rhs.adaptMaxFontSize_ &&
33            adaptFontSizeStep_ == rhs.adaptFontSizeStep_ && lineHeight_ == rhs.lineHeight_ &&
34            fontWeight_ == rhs.fontWeight_ && fontStyle_ == rhs.fontStyle_ && textBaseline_ == rhs.textBaseline_ &&
35            textOverflow_ == rhs.textOverflow_ && textAlign_ == rhs.textAlign_ && textColor_ == rhs.textColor_ &&
36            textDecoration_ == rhs.textDecoration_ && textShadows_ == rhs.textShadows_ &&
37            letterSpacing_ == rhs.letterSpacing_ && maxLines_ == rhs.maxLines_ && adaptTextSize_ == rhs.adaptTextSize_ &&
38            allowScale_ == rhs.allowScale_ && wordBreak_ == rhs.wordBreak_ &&
39            textDecorationColor_ == rhs.textDecorationColor_ && textCase_ == rhs.textCase_ &&
40            baselineOffset_ == rhs.baselineOffset_ && adaptHeight_ == rhs.adaptHeight_ &&
41            textIndent_ == rhs.textIndent_ && verticalAlign_ == rhs.verticalAlign_ && wordSpacing_ == rhs.wordSpacing_;
42 }
43 
operator !=(const TextStyle & rhs) const44 bool TextStyle::operator!=(const TextStyle& rhs) const
45 {
46     return !(rhs == *this);
47 }
48 
SetAdaptTextSize(const Dimension & maxFontSize,const Dimension & minFontSize,const Dimension & fontSizeStep)49 void TextStyle::SetAdaptTextSize(
50     const Dimension& maxFontSize, const Dimension& minFontSize, const Dimension& fontSizeStep)
51 {
52     adaptMaxFontSize_ = maxFontSize;
53     adaptMinFontSize_ = minFontSize;
54     adaptFontSizeStep_ = fontSizeStep;
55     adaptTextSize_ = true;
56 }
57 
58 } // namespace OHOS::Ace
59