1 /*
2 * Copyright (c) 2023 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 "texgine_font_style.h"
17
18 namespace OHOS {
19 namespace Rosen {
20 namespace TextEngine {
TexgineFontStyle()21 TexgineFontStyle::TexgineFontStyle(): fontStyle_(std::make_shared<SkFontStyle>())
22 {
23 }
24
TexgineFontStyle(int weight,int width,Slant slant)25 TexgineFontStyle::TexgineFontStyle(
26 int weight, int width, Slant slant): fontStyle_(
27 std::make_shared<SkFontStyle>(weight, width, static_cast<SkFontStyle::Slant>(slant)))
28 {
29 }
30
TexgineFontStyle(std::shared_ptr<SkFontStyle> style)31 TexgineFontStyle::TexgineFontStyle(std::shared_ptr<SkFontStyle> style)
32 {
33 fontStyle_ = style;
34 }
35
GetFontStyle() const36 std::shared_ptr<SkFontStyle> TexgineFontStyle::GetFontStyle() const
37 {
38 return fontStyle_;
39 }
40
SetFontStyle(const std::shared_ptr<SkFontStyle> fontStyle)41 void TexgineFontStyle::SetFontStyle(const std::shared_ptr<SkFontStyle> fontStyle)
42 {
43 fontStyle_ = fontStyle;
44 }
45
SetStyle(const SkFontStyle & style)46 void TexgineFontStyle::SetStyle(const SkFontStyle &style)
47 {
48 if (fontStyle_ == nullptr) {
49 return;
50 }
51 *fontStyle_ = style;
52 }
53 } // namespace TextEngine
54 } // namespace Rosen
55 } // namespace OHOS
56