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 "text/font_style_set.h"
17 
18 #include "impl_interface/font_style_set_impl.h"
19 #include "static_factory.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 namespace Drawing {
FontStyleSet(std::shared_ptr<FontStyleSetImpl> fontStyleSetImpl)24 FontStyleSet::FontStyleSet(std::shared_ptr<FontStyleSetImpl> fontStyleSetImpl) noexcept
25     : fontStyleSetImpl_(fontStyleSetImpl) {}
26 
CreateTypeface(int index)27 Typeface* FontStyleSet::CreateTypeface(int index)
28 {
29     if (fontStyleSetImpl_) {
30         return fontStyleSetImpl_->CreateTypeface(index);
31     }
32     return nullptr;
33 }
34 
GetStyle(int32_t index,FontStyle * fontStyle,std::string * styleName)35 void FontStyleSet::GetStyle(int32_t index, FontStyle* fontStyle, std::string* styleName)
36 {
37     if (fontStyleSetImpl_) {
38         fontStyleSetImpl_->GetStyle(index, fontStyle, styleName);
39     }
40 }
41 
MatchStyle(const FontStyle & pattern)42 Typeface* FontStyleSet::MatchStyle(const FontStyle& pattern)
43 {
44     if (fontStyleSetImpl_) {
45         return fontStyleSetImpl_->MatchStyle(pattern);
46     }
47     return nullptr;
48 }
49 
Count()50 int FontStyleSet::Count()
51 {
52     if (fontStyleSetImpl_) {
53         return fontStyleSetImpl_->Count();
54     }
55     return 0;
56 }
57 
58 } // namespace Drawing
59 } // namespace Rosen
60 } // namespace OHOS
61