• 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 ROSEN_MODULES_TEXGINE_SRC_TEXGINE_FONT_STYLE_SET_H
17 #define ROSEN_MODULES_TEXGINE_SRC_TEXGINE_FONT_STYLE_SET_H
18 
19 #include <memory>
20 
21 #ifndef USE_ROSEN_DRAWING
22 #include <include/core/SkFontMgr.h>
23 #else
24 #include "drawing.h"
25 #endif
26 
27 #include "texgine_font_style.h"
28 #include "texgine_string.h"
29 #include "texgine_typeface.h"
30 
31 namespace OHOS {
32 namespace Rosen {
33 namespace TextEngine {
34 class TexgineFontStyleSet {
35 public:
36 #ifndef USE_ROSEN_DRAWING
37     explicit TexgineFontStyleSet(SkFontStyleSet *set);
38     ~TexgineFontStyleSet();
39 #else
40     explicit TexgineFontStyleSet(RSFontStyleSet *set);
41     ~TexgineFontStyleSet();
42 #endif
43 
44     /*
45      * @brief Return the count of typeface
46      */
47     int Count() const;
48 
49     /*
50      * @brief Get thr font style for the specified typeface
51      * @param index The index of a typeface
52      * @param style The style value that returned to the caller
53      * @param name  The style name that returned to the caller
54      */
55     void GetStyle(const int index, std::shared_ptr<TexgineFontStyle> style, std::shared_ptr<TexgineString> name) const;
56 
57     /*
58      * @brief To create a typeface
59      * @param index The the index of the typeface in this font style set
60      */
61     std::shared_ptr<TexgineTypeface> CreateTypeface(int index);
62 
63     /*
64      * @brief To get the closest matching typeface
65      * @param pattern The style value to be matching
66      */
67     std::shared_ptr<TexgineTypeface> MatchStyle(const std::shared_ptr<TexgineFontStyle> pattern);
68 
69     /*
70      * @brief Returns the SkFontStyleSet in TexgineFontStyleSet
71      */
72 #ifndef USE_ROSEN_DRAWING
GetFontStyleSet()73     SkFontStyleSet *GetFontStyleSet() const
74 #else
75     RSFontStyleSet *GetFontStyleSet() const
76 #endif
77     {
78         return set_;
79     }
80 
81 private:
82 #ifndef USE_ROSEN_DRAWING
83     SkFontStyleSet *set_ = nullptr;
84 #else
85     RSFontStyleSet *set_ = nullptr;
86 #endif
87 };
88 } // namespace TextEngine
89 } // namespace Rosen
90 } // namespace OHOS
91 
92 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_FONT_STYLE_SET_H
93