• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SKIA_FONT_STYLE_SET_H
17 #define SKIA_FONT_STYLE_SET_H
18 
19 #include <memory>
20 
21 #include "include/core/SkFontMgr.h"
22 
23 #include "text/font_style_set.h"
24 #include "impl_interface/font_style_set_impl.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 namespace Drawing {
29 class SkiaFontStyleSet : public FontStyleSetImpl {
30 public:
31     static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
32 
33     explicit SkiaFontStyleSet(sk_sp<SkFontStyleSet> skFontStyleSet);
34     virtual ~SkiaFontStyleSet() = default;
35 
GetType()36     AdapterType GetType() const override
37     {
38         return AdapterType::SKIA_ADAPTER;
39     }
40 
41     Typeface* CreateTypeface(int index) override;
42 
43     void GetStyle(int32_t index, FontStyle* fontStyle, std::string* styleName) override;
44 
45     Typeface* MatchStyle(const FontStyle& pattern) override;
46 
47     int Count() override;
48 
49 private:
50     sk_sp<SkFontStyleSet> skFontStyleSet_;
51 };
52 } // namespace Drawing
53 } // namespace Rosen
54 } // namespace OHOS
55 #endif