1 /*
2  * Copyright (c) 2024 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_MGR_H
17 #define C_INCLUDE_DRAWING_FONT_MGR_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 12
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_font_mgr.h
33  *
34  * @brief Declares functions related to the <b>fontmgr</b> object in the drawing module.
35  *
36  * @kit ArkGraphics2D
37  * @library libnative_drawing.so
38  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
39  * @since 12
40  * @version 1.0
41  */
42 
43 #include "drawing_types.h"
44 #include "drawing_text_typography.h"
45 #include <stdint.h>
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /**
52  * @brief Creates an <b>OH_Drawing_FontMgr</b> object.
53  *
54  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
55  * @return Returns the pointer to the <b>OH_Drawing_FontMgr</b> object created.
56  * @since 12
57  * @version 1.0
58  */
59 OH_Drawing_FontMgr* OH_Drawing_FontMgrCreate(void);
60 
61 /**
62  * @brief Releases the memory occupied by an <b>OH_Drawing_FontMgr</b> object.
63  *
64  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
65  * @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
66  * @since 12
67  * @version 1.0
68  */
69 void OH_Drawing_FontMgrDestroy(OH_Drawing_FontMgr*);
70 
71 /**
72  * @brief Gets the count of font families.
73  *
74  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
75  * @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
76  * @return Returns the count of font families.
77  * @since 12
78  * @version 1.0
79  */
80 int OH_Drawing_FontMgrGetFamilyCount(OH_Drawing_FontMgr*);
81 
82 /**
83  * @brief Gets the font family name by the index.
84  *
85  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
86  * @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
87  * @param index Indicates the index to get the font family name.
88  * @return Returns the font family name corresponding to the index value.
89  * @since 12
90  * @version 1.0
91  */
92 char* OH_Drawing_FontMgrGetFamilyName(OH_Drawing_FontMgr*, int index);
93 
94 /**
95  * @brief Releases the memory occupied by font family name.
96  *
97  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
98  * @param familyName Indicates the font family name.
99  * @since 12
100  * @version 1.0
101  */
102 void OH_Drawing_FontMgrDestroyFamilyName(char* familyName);
103 
104 /**
105  * @brief Creates an <b>OH_Drawing_FontStyleSet</b> object by <b>OH_Drawing_FontMgr</b> object.
106  *
107  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
108  * @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
109  * @param index Indicates the index used to get the font style set object from the font manager object.
110  * @return Returns the pointer to the <b>OH_Drawing_FontStyleSet</b> object created.
111  * @since 12
112  * @version 1.0
113  */
114 OH_Drawing_FontStyleSet* OH_Drawing_FontMgrCreateFontStyleSet(OH_Drawing_FontMgr*, int index);
115 
116 /**
117  * @brief Releases the memory occupied by an <b>OH_Drawing_FontStyleSet</b> object.
118  *
119  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
120  * @param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
121  * @since 12
122  * @version 1.0
123  */
124 void OH_Drawing_FontMgrDestroyFontStyleSet(OH_Drawing_FontStyleSet*);
125 
126 /**
127  * @brief Get the pointer to an <b>OH_Drawing_FontStyleSet</b> object for the given font style set family name.
128  *
129  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
130  * @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
131  * @param familyName Indicates the family name of a font style set to be matched.
132  * @return Returns the pointer to the <b>OH_Drawing_FontStyleSet</b> object matched.
133  * @since 12
134  * @version 1.0
135  */
136 OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(OH_Drawing_FontMgr*, const char* familyName);
137 
138 /**
139  * @brief Get the pointer to an <b>OH_Drawing_Typeface</b> object based on the given font style and family name.
140  *
141  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
142  * @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
143  * @param familyName Indicates the family name of a font style set to be matched.
144  * @param OH_Drawing_FontStyleStruct Indicates an <b>OH_Drawing_FontStyleStruct</b> object.
145  * @return Returns the pointer to the <b>OH_Drawing_Typeface</b> object matched.
146  * @since 12
147  * @version 1.0
148  */
149 OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(OH_Drawing_FontMgr*,
150     const char* familyName, OH_Drawing_FontStyleStruct fontStyle);
151 
152 /**
153  * @brief Get the pointer to an <b>OH_Drawing_Typeface</b> object for the given character.
154  *
155  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
156  * @param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
157  * @param familyName Indicates the family name of a font style set to be matched.
158  * @param OH_Drawing_FontStyleStruct Indicates an <b>OH_Drawing_FontStyleStruct</b> object.
159  * @param bcp47 Indicates an array of languages which indicate the language of character.
160  * @param bcp47Count Indicates the array size of bcp47.
161  * @param character Indicates a UTF8 value to be matched.
162  * @return Returns the pointer to the <b>OH_Drawing_Typeface</b> object matched.
163  * @since 12
164  * @version 1.0
165  */
166 OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(OH_Drawing_FontMgr*, const char* familyName,
167     OH_Drawing_FontStyleStruct fontStyle, const char* bcp47[], int bcp47Count, int32_t character);
168 
169 /**
170  * @brief Create a typeface for the given index.
171  *
172  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
173  * @param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
174  * @param index Indicates the index of the typeface in this fontStyleSet.
175  * @return If successful, return a pointer to <b>OH_Drawing_Typeface</b> object; if failed, return nullptr.
176  * @since 12
177  * @version 1.0
178  */
179 OH_Drawing_Typeface* OH_Drawing_FontStyleSetCreateTypeface(OH_Drawing_FontStyleSet*, int index);
180 
181  /**
182  * @brief Get font style for the specified typeface.
183  *
184  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
185  * @param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
186  * @param index Indicates the index of the typeface in this fontStyleSet.
187  * @param styleName Indicates the style name returned.
188  * @return Return the <b>OH_Drawing_FontStyleStruct<b> structure.
189  * @since 12
190  * @version 1.0
191  */
192 OH_Drawing_FontStyleStruct OH_Drawing_FontStyleSetGetStyle(OH_Drawing_FontStyleSet*, int32_t index,
193     char** styleName);
194 
195  /**
196  * @brief Releases the memory  styleName string.
197  *
198  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
199  * @param styleName Indicates the pointer to a string type.
200  * @since 12
201  * @version 1.0
202  */
203 void OH_Drawing_FontStyleSetFreeStyleName(char** styleName);
204 
205 /**
206  * @brief Get the closest matching typeface.
207  *
208  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
209  * @param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
210  * @param fontStyleStruct Indicates the <b>OH_Drawing_FontStyleStruct</b> structure.
211  * @return A pointer to matched <b>OH_Drawing_Typeface</b>.
212  * @since 12
213  * @version 1.0
214  */
215 OH_Drawing_Typeface* OH_Drawing_FontStyleSetMatchStyle(OH_Drawing_FontStyleSet*,
216     OH_Drawing_FontStyleStruct fontStyleStruct);
217 
218 /**
219  * @brief Get the count of typeface.
220  *
221  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
222  * @param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
223  * @return The count of typeface in this font style set.
224  * @since 12
225  * @version 1.0
226  */
227 int OH_Drawing_FontStyleSetCount(OH_Drawing_FontStyleSet*);
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 /** @} */
233 #endif