• 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_DYNAMIC_FONT_STYLE_SET_H
17 #define ROSEN_MODULES_TEXGINE_SRC_DYNAMIC_FONT_STYLE_SET_H
18 
19 #include "texgine_font_style.h"
20 #include "texgine_font_style_set.h"
21 #include "typeface.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace TextEngine {
26 class DynamicFontStyleSet {
27 public:
28     explicit DynamicFontStyleSet(std::unique_ptr<Typeface> typeface);
29 
30     /*
31      * @brief Return the count of typeface
32      */
33     int Count() const;
34 
35     /*
36      * @brief Get the font style of typeface
37      * @param index The index of the typeface in font config
38      * @param style The out param of typeface style
39      * @param name The name of typeface
40      */
41     void GetStyle(int index, std::shared_ptr<TexgineFontStyle> style, std::shared_ptr<TexgineString> name) const;
42 
43     /*
44      * @brief create typeface by index
45      */
46     std::shared_ptr<TexgineTypeface> CreateTypeface(int index);
47 
48     /*
49      * @brief  Matching typeface by font style
50      * @param  pattern The font style of typeface
51      * @Return The typeface that font style is pattern
52      */
53     std::shared_ptr<TexgineTypeface> MatchStyle(std::shared_ptr<TexgineFontStyle> pattern);
54 
55 private:
56     std::unique_ptr<Typeface> typeface_ = nullptr;
57 };
58 } // namespace TextEngine
59 } // namespace Rosen
60 } // namespace OHOS
61 
62 #endif // ROSEN_MODULES_TEXGINE_SRC_DYNAMIC_FONT_STYLE_SET_H
63