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 FONT_STYLE_SET_H
17 #define FONT_STYLE_SET_H
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "text/font_style.h"
23 #include "text/typeface.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace Drawing {
28 class FontStyleSetImpl;
29 
30 class DRAWING_API FontStyleSet {
31 public:
32     explicit FontStyleSet(std::shared_ptr<FontStyleSetImpl> fontStyleSetImpl) noexcept;
33     virtual ~FontStyleSet() = default;
34 
35     /**
36      * @brief        Create a typeface for the given index.
37      * @param index  The index of the typeface in this fontStyleSet.
38      * @return       If successful, return typeface. else, return nullptr.
39      */
40     Typeface* CreateTypeface(int index);
41 
42     /**
43      * @brief            Get font style for the specified typeface.
44      * @param index      The index of the typeface in this fontStyleSet.
45      * @param fontStyle  The font style returned to the caller.
46      * @param styleName  The style name returned to the caller.
47      */
48     void GetStyle(int32_t index, FontStyle* fontStyle, std::string* styleName);
49 
50     /**
51      * @brief          Get the closest matching typeface.
52      * @param pattern  The font style to be matching.
53      * @return         A pointer to matched typeface.
54      */
55     Typeface* MatchStyle(const FontStyle& pattern);
56 
57     /**
58      * @brief   Get the count of typeface.
59      * @return  The count of typeface in this font style set.
60      */
61     int Count();
62 
63 private:
64     std::shared_ptr<FontStyleSetImpl> fontStyleSetImpl_;
65 };
66 } // namespace Drawing
67 } // namespace Rosen
68 } // namespace OHOS
69 #endif