• 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 C_INCLUDE_DRAWING_FONT_H
17 #define C_INCLUDE_DRAWING_FONT_H
18 
19 /**
20  * @addtogroup Drawing
21  * @{
22  *
23  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
26  *
27  * @since 11
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_font.h
33  *
34  * @brief Declares functions related to the <b>font</b> object in the drawing module.
35  *
36  * @since 11
37  * @version 1.0
38  */
39 
40 #include "drawing_types.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Creates an <b>OH_Drawing_Font</b> object.
48  *
49  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
50  * @return Returns the pointer to the <b>OH_Drawing_Font</b> object created.
51  * @since 11
52  * @version 1.0
53  */
54 OH_Drawing_Font* OH_Drawing_FontCreate(void);
55 
56 /**
57  * @brief Sets an <b>OH_Drawing_Typeface</b> object for an <b>OH_Drawing_Font</b> object.
58  *
59  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
60  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
61  * @param OH_Drawing_Typeface Indicates the pointer to an <b>OH_Drawing_Typeface</b> object.
62  * @since 11
63  * @version 1.0
64  */
65 void OH_Drawing_FontSetTypeface(OH_Drawing_Font*, OH_Drawing_Typeface*);
66 
67 /**
68  * @brief Gets an <b>OH_Drawing_Typeface</b> object from the <b>OH_Drawing_Typeface</b> object.
69  *
70  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
71  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
72  * @return OH_Drawing_Typeface Indicates the pointer to an <b>OH_Drawing_Typeface</b> object.
73  * @since 12
74  * @version 1.0
75  */
76 OH_Drawing_Typeface* OH_Drawing_FontGetTypeface(OH_Drawing_Font*);
77 
78 /**
79  * @brief Set Font and glyph metrics should ignore hinting and rounding.
80  *
81  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
82  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
83  * @param bool Should ignore hinting and rounding.
84  * @since 12
85  * @version 1.0
86  */
87 void OH_Drawing_FontSetLinearMetrics(OH_Drawing_Font*, bool);
88 
89 /**
90  * @brief Sets text size for an <b>OH_Drawing_Font</b> object.
91  *
92  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
93  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
94  * @param textSize Indicates the text size.
95  * @since 11
96  * @version 1.0
97  */
98 void OH_Drawing_FontSetTextSize(OH_Drawing_Font*, float textSize);
99 
100 /**
101  * @brief Enables or disables linearly scalable font for an <b>OH_Drawing_Font</b> object.
102  *
103  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
104  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
105  * @param isLinearText Indicates whether to enable linearly scalable font.
106  * @since 11
107  * @version 1.0
108  */
109 void OH_Drawing_FontSetLinearText(OH_Drawing_Font*, bool isLinearText);
110 
111 /**
112  * @brief Sets text skew on x-axis for an <b>OH_Drawing_Font</b> object.
113  *
114  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
115  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
116  * @param skewX Indicates the additional shear on x-axis relative to y-axis.
117  * @since 11
118  * @version 1.0
119  */
120 void OH_Drawing_FontSetTextSkewX(OH_Drawing_Font*, float skewX);
121 
122 /**
123  * @brief Enables or disables to increase stroke width to approximate bold fonts for an <b>OH_Drawing_Font</b> object.
124  *
125  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
126  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
127  * @param isFakeBoldText Indicates whether to enable to increase stroke width.
128  * @since 11
129  * @version 1.0
130  */
131 void OH_Drawing_FontSetFakeBoldText(OH_Drawing_Font*, bool isFakeBoldText);
132 
133 /**
134  * @brief Destroys an <b>OH_Drawing_Font</b> object and reclaims the memory occupied by the object.
135  *
136  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
137  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
138  * @since 11
139  * @version 1.0
140  */
141 void OH_Drawing_FontDestroy(OH_Drawing_Font*);
142 
143 /**
144  * @brief Defines a run, supplies storage for the metrics of an SkFont.
145  *
146  * @since 12
147  * @version 1.0
148  */
149 typedef struct {
150     /** storage for top in font metrics */
151     float top;
152     /** storage for ascent in font metrics */
153     float ascent;
154     /** storage for descent in font metrics */
155     float descent;
156     /** storage for bottom in font metrics */
157     float bottom;
158     /** storage for leading in font metrics */
159     float leading;
160 } OH_Drawing_Font_Metrics;
161 
162 /**
163  * @brief Obtains the metrics of a font.
164  *
165  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
166  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
167  * @param OH_Drawing_Font_Metrics Indicates the pointer to an <b>OH_Drawing_Font_Metrics</b> object.
168  * @return Returns a float variable that recommended spacing between lines.
169  * Returns -1 if OH_Drawing_Font or OH_Drawing_Font_Metrics is nullptr.
170  * @since 12
171  * @version 1.0
172  */
173 float OH_Drawing_FontGetMetrics(OH_Drawing_Font*, OH_Drawing_Font_Metrics*);
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 /** @} */
179 #endif
180