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_DRAWING_TEXGINE_FONT_H
17 #define ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_FONT_H
18 
19 #include <memory>
20 
21 #include "drawing.h"
22 
23 #include "texgine_font_metrics.h"
24 #include "texgine_typeface.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 namespace TextEngine {
29 class TexgineFont {
30 public:
31     enum FontEdging : uint8_t {
32         ALIAS,
33         ANTIALIAS,
34         SUBPIXEL_ANTIALIAS,
35     };
36 
37     enum TexgineFontHinting : uint8_t {
38         NONE,
39         SLIGHT,
40         NORMAL,
41         FULL,
42     };
43 
44     std::shared_ptr<RSFont> GetFont() const;
45 
46     /*
47      * @brief Set typeface to SkFont
48      */
49     void SetTypeface(const std::shared_ptr<TexgineTypeface> tf);
50 
51     /*
52      * @brief Set font size
53      */
54     void SetSize(float textSize);
55 
56     /*
57      * @brief Get metrics of the font
58      */
59     float GetMetrics(std::shared_ptr<TexgineFontMetrics> metrics) const;
60 
61     /*
62      * @brief Get metrics of the font
63      */
64     void SetSubpixel(const bool isSubpixel);
65 
66     /*
67      * @brief Set subpixel positioning
68      */
69     void SetEdging(const FontEdging edging);
70 
71     /*
72      * @brief Set font optimization mode
73      */
74     void SetHinting(const TexgineFontHinting hinting);
75 
76     /*
77      * @brief Set font default non-bold italics mode
78      */
79     void SetSkewX();
80 
81     void SetBold();
82 private:
83     std::shared_ptr<RSFont> font_ = std::make_shared<RSFont>();
84 };
85 } // namespace TextEngine
86 } // namespace Rosen
87 } // namespace OHOS
88 
89 #endif // ROSEN_MODULES_TEXGINE_SRC_TEXGINE_DRAWING_TEXGINE_FONT_H
90