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