• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, Hardware
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 #include "gtest/gtest.h"
17 #include "drawing_font_mgr.h"
18 #include "drawing_text_typography.h"
19 #include "drawing_typeface.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class OH_Drawing_FontMgrTest : public testing::Test {
28 };
29 
30 /*
31  * @tc.name: OH_Drawing_FontMgrTest001
32  * @tc.desc: test for creating and destroying font manager.
33  * @tc.type: FUNC
34  */
35 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest001, Function | MediumTest | Level1)
36 {
37     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
38     EXPECT_NE(mgr, nullptr);
39     OH_Drawing_FontMgrDestroy(mgr);
40 }
41 
42 /*
43  * @tc.name: OH_Drawing_FontMgrTest002
44  * @tc.desc: test for getting family name.
45  * @tc.type: FUNC
46  */
47 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest002, Function | MediumTest | Level1)
48 {
49     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
50     EXPECT_NE(mgr, nullptr);
51     int count = OH_Drawing_FontMgrGetFamilyCount(mgr);
52     EXPECT_TRUE(count > 0);
53 
54     char *familyName = OH_Drawing_FontMgrGetFamilyName(mgr, 0);
55     OH_Drawing_FontMgrDestroyFamilyName(familyName);
56 
57     OH_Drawing_FontMgrDestroy(mgr);
58 }
59 
60 /*
61  * @tc.name: OH_Drawing_FontMgrTest003
62  * @tc.desc: test for creating and destroying font style set by font mannager.
63  * @tc.type: FUNC
64  */
65 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest003, Function | MediumTest | Level1)
66 {
67     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
68     EXPECT_NE(mgr, nullptr);
69 
70     OH_Drawing_FontStyleSet* fontStyleSet = OH_Drawing_FontMgrCreateFontStyleSet(mgr, 0);
71     EXPECT_NE(fontStyleSet, nullptr);
72     OH_Drawing_FontMgrDestroyFontStyleSet(fontStyleSet);
73 
74     OH_Drawing_FontMgrDestroy(mgr);
75 }
76 
77 /*
78  * @tc.name: OH_Drawing_FontMgrTest004
79  * @tc.desc: test for matching font family by family name.
80  * @tc.type: FUNC
81  */
82 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest004, Function | MediumTest | Level1)
83 {
84     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
85     EXPECT_NE(mgr, nullptr);
86     const char* matchFamilyName = "HarmonyOS-Sans";
87     OH_Drawing_FontStyleSet* fontStyleSet = OH_Drawing_FontMgrMatchFamily(mgr, matchFamilyName);
88     EXPECT_NE(fontStyleSet, nullptr);
89     OH_Drawing_FontMgrDestroyFontStyleSet(fontStyleSet);
90 
91     OH_Drawing_FontMgrDestroy(mgr);
92 }
93 
94 
95 /*
96  * @tc.name: OH_Drawing_FontMgrTest005
97  * @tc.desc: test for matching font typeface by family name and font style.
98  * @tc.type: FUNC
99  */
100 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest005, Function | MediumTest | Level1)
101 {
102     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
103     EXPECT_NE(mgr, nullptr);
104     const char* matchFamilyName = "HarmonyOS-Sans";
105     OH_Drawing_FontStyleStruct normalStyle;
106     normalStyle.weight = FONT_WEIGHT_400;
107     normalStyle.width = FONT_WIDTH_NORMAL;
108     normalStyle.slant = FONT_STYLE_NORMAL;
109     OH_Drawing_Typeface *typeface = OH_Drawing_FontMgrMatchFamilyStyle(mgr, matchFamilyName, normalStyle);
110     EXPECT_NE(typeface, nullptr);
111     OH_Drawing_TypefaceDestroy(typeface);
112 
113     OH_Drawing_FontMgrDestroy(mgr);
114 }
115 
116 /*
117  * @tc.name: OH_Drawing_FontMgrTest006
118  * @tc.desc: test for matching font typeface by family name, font style and specific character.
119  * @tc.type: FUNC
120  */
121 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest006, Function | MediumTest | Level1)
122 {
123     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
124     EXPECT_NE(mgr, nullptr);
125 
126     const char* matchFamilyName = "HarmonyOS-Sans";
127     OH_Drawing_FontStyleStruct normalStyle;
128     normalStyle.weight = FONT_WEIGHT_400;
129     normalStyle.width = FONT_WIDTH_NORMAL;
130     normalStyle.slant = FONT_STYLE_NORMAL;
131 
132     const char *bcp47[] = {"zh-Hans", "zh-CN"};
133     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
134                                                                                     normalStyle, bcp47, 1, ' ');
135     EXPECT_NE(CharTypeface, nullptr);
136     OH_Drawing_TypefaceDestroy(CharTypeface);
137 
138     OH_Drawing_FontMgrDestroy(mgr);
139 }
140 
141 /*
142  * @tc.name: OH_Drawing_FontMgrTest007
143  * @tc.desc: test for getting family name.
144  * @tc.type: FUNC
145  */
146 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest007, Function | MediumTest | Level1)
147 {
148     int count = OH_Drawing_FontMgrGetFamilyCount(nullptr);
149     EXPECT_TRUE(count == 0);
150     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
151     EXPECT_NE(mgr, nullptr);
152     char *familyName = OH_Drawing_FontMgrGetFamilyName(nullptr, 0);
153     EXPECT_TRUE(familyName == nullptr);
154     OH_Drawing_FontMgrDestroyFamilyName(familyName);
155     OH_Drawing_FontMgrDestroy(mgr);
156 }
157 
158 /*
159  * @tc.name: OH_Drawing_FontMgrTest008
160  * @tc.desc: test for matching family style.
161  * @tc.type: FUNC
162  */
163 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest008, Function | MediumTest | Level1)
164 {
165     OH_Drawing_FontStyleSet* fontStyleSet = OH_Drawing_FontMgrCreateFontStyleSet(nullptr, 0);
166     EXPECT_TRUE(fontStyleSet == nullptr);
167     const char* matchFamilyName = "HarmonyOS-Sans";
168     fontStyleSet = OH_Drawing_FontMgrMatchFamily(nullptr, matchFamilyName);
169     EXPECT_TRUE(fontStyleSet == nullptr);
170 
171     OH_Drawing_FontStyleStruct normalStyle;
172     normalStyle.weight = FONT_WEIGHT_400;
173     normalStyle.width = FONT_WIDTH_NORMAL;
174     normalStyle.slant = FONT_STYLE_NORMAL;
175     OH_Drawing_Typeface *typeface = OH_Drawing_FontMgrMatchFamilyStyle(nullptr, matchFamilyName, normalStyle);
176     EXPECT_TRUE(typeface == nullptr);
177 }
178 
179 /*
180  * @tc.name: OH_Drawing_FontMgrTest009
181  * @tc.desc: test for matching family style character.
182  * @tc.type: FUNC
183  */
184 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest009, Function | MediumTest | Level1)
185 {
186     const char* matchFamilyName = "HarmonyOS-Sans";
187     OH_Drawing_FontStyleStruct normalStyle;
188     normalStyle.weight = FONT_WEIGHT_400;
189     normalStyle.width = FONT_WIDTH_NORMAL;
190     normalStyle.slant = FONT_STYLE_NORMAL;
191 
192     const char *bcp47[] = {"zh-Hans", "zh-CN"};
193     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(nullptr, matchFamilyName,
194                                                                                     normalStyle, bcp47, 1, ' ');
195     EXPECT_TRUE(CharTypeface == nullptr);
196 }
197 
198 /*
199  * @tc.name: OH_Drawing_FontMgrTest010
200  * @tc.desc: test for create a typeface for the given index.
201  * @tc.type: FUNC
202  */
203 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest010, Function | MediumTest | Level1)
204 {
205     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
206     OH_Drawing_FontStyleSet* fontStyleSet = OH_Drawing_FontMgrCreateFontStyleSet(mgr, 0);
207     OH_Drawing_Typeface *typeface = OH_Drawing_FontStyleSetCreateTypeface(fontStyleSet, 0);
208     EXPECT_NE(typeface, nullptr);
209     typeface = OH_Drawing_FontStyleSetCreateTypeface(nullptr, 0);
210     EXPECT_TRUE(typeface == nullptr);
211     OH_Drawing_FontMgrDestroyFontStyleSet(fontStyleSet);
212     OH_Drawing_TypefaceDestroy(typeface);
213     OH_Drawing_FontMgrDestroy(mgr);
214 }
215 
216 /*
217  * @tc.name: OH_Drawing_FontMgrTest011
218  * @tc.desc: test for get font style struct.
219  * @tc.type: FUNC
220  */
221 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest011, Function | MediumTest | Level1)
222 {
223     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
224     OH_Drawing_FontStyleSet* fontStyleSet = OH_Drawing_FontMgrCreateFontStyleSet(mgr, 0);
225     OH_Drawing_FontStyleStruct normalStyle;
226     char** styleName = nullptr;
227     normalStyle = OH_Drawing_FontStyleSetGetStyle(fontStyleSet, 0, styleName);
228     EXPECT_TRUE(normalStyle.weight == FONT_WEIGHT_400);
229     OH_Drawing_FontStyleSetFreeStyleName(styleName);
230     OH_Drawing_FontMgrDestroyFontStyleSet(fontStyleSet);
231     OH_Drawing_FontMgrDestroy(mgr);
232 }
233 
234 /*
235  * @tc.name: OH_Drawing_FontMgrTest012
236  * @tc.desc: test for get typeface by match style.
237  * @tc.type: FUNC
238  */
239 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest012, Function | MediumTest | Level1)
240 {
241     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
242     OH_Drawing_FontStyleSet* fontStyleSet = OH_Drawing_FontMgrCreateFontStyleSet(mgr, 0);
243     OH_Drawing_FontStyleStruct normalStyle;
244     normalStyle.weight = FONT_WEIGHT_400;
245     normalStyle.width = FONT_WIDTH_NORMAL;
246     normalStyle.slant = FONT_STYLE_NORMAL;
247     OH_Drawing_Typeface* typeface = OH_Drawing_FontStyleSetMatchStyle(fontStyleSet, normalStyle);
248     EXPECT_NE(typeface, nullptr);
249 
250     typeface = OH_Drawing_FontStyleSetMatchStyle(nullptr, normalStyle);
251     EXPECT_TRUE(typeface == nullptr);
252     OH_Drawing_FontMgrDestroyFontStyleSet(fontStyleSet);
253     OH_Drawing_TypefaceDestroy(typeface);
254     OH_Drawing_FontMgrDestroy(mgr);
255 }
256 
257 /*
258  * @tc.name: OH_Drawing_FontMgrTest013
259  * @tc.desc: test for get font style set.
260  * @tc.type: FUNC
261  */
262 HWTEST_F(OH_Drawing_FontMgrTest, OH_Drawing_FontMgrTest013, Function | MediumTest | Level1)
263 {
264     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
265     OH_Drawing_FontStyleSet* fontStyleSet = OH_Drawing_FontMgrCreateFontStyleSet(mgr, 0);
266     int count = OH_Drawing_FontStyleSetCount(fontStyleSet);
267     EXPECT_TRUE(count > 0);
268 
269     count = OH_Drawing_FontStyleSetCount(nullptr);
270     EXPECT_TRUE(count == 0);
271     OH_Drawing_FontMgrDestroyFontStyleSet(fontStyleSet);
272     OH_Drawing_FontMgrDestroy(mgr);
273 }
274 
275 /*
276  * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0100
277  * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterNormalBcp47Null
278  * @tc.desc: test for matching font is not a null pointer, but points to the default font, when bcp47 is a null pointer
279  * @tc.size: MediumTest
280  * @tc.type: Function
281  * @tc.level: Level 0
282  */
283 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterNormalBcp47Null,
284     Function | MediumTest | Level1)
285 {
286     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
287     EXPECT_NE(mgr, nullptr);
288 
289     const char* matchFamilyName = "HarmonyOS-Sans";
290     OH_Drawing_FontStyleStruct normalStyle;
291     normalStyle.weight = FONT_WEIGHT_400;
292     normalStyle.width = FONT_WIDTH_NORMAL;
293     normalStyle.slant = FONT_STYLE_NORMAL;
294 
295     OH_Drawing_Typeface *typeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
296                                                                                     normalStyle, nullptr, 0, ' ');
297     EXPECT_NE(typeface, nullptr);
298     OH_Drawing_TypefaceDestroy(typeface);
299 
300     OH_Drawing_FontMgrDestroy(mgr);
301 }
302 
303 /*
304 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0200
305 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterEmptyBcp47
306 * @tc.desc: Test for matching font typeface with empty bcp47 array.
307 * @tc.size: MediumTest
308 * @tc.type: Function
309 * @tc.level: Level 0
310 */
311 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterEmptyBcp47,
312     Function | MediumTest | Level1)
313 {
314     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
315     EXPECT_NE(mgr, nullptr);
316 
317     const char* matchFamilyName = "HarmonyOS-Sans";
318     OH_Drawing_FontStyleStruct normalStyle;
319     normalStyle.weight = FONT_WEIGHT_400;
320     normalStyle.width = FONT_WIDTH_NORMAL;
321     normalStyle.slant = FONT_STYLE_NORMAL;
322 
323     const char* bcp47[] = {};
324     OH_Drawing_Typeface *typeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(
325         mgr, matchFamilyName, normalStyle, bcp47, 0, ' ');
326 
327     EXPECT_NE(typeface, nullptr);
328     OH_Drawing_TypefaceDestroy(typeface);
329     OH_Drawing_FontMgrDestroy(mgr);
330 }
331 
332 /*
333 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0300
334 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight900
335 * @tc.desc: Test for matching font typeface with weight 900.
336 * @tc.size: MediumTest
337 * @tc.type: Function
338 * @tc.level: Level 0
339 */
340 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight900, Function | MediumTest | Level1)
341 {
342     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
343     EXPECT_NE(mgr, nullptr);
344 
345     const char* matchFamilyName = "HarmonyOS-Sans";
346     OH_Drawing_FontStyleStruct normalStyle;
347     normalStyle.weight = FONT_WEIGHT_900;
348     normalStyle.width = FONT_WIDTH_NORMAL;
349     normalStyle.slant = FONT_STYLE_NORMAL;
350 
351     const char *bcp47[] = {"zh-Hans", "zh-CN"};
352     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
353                                                                                     normalStyle, bcp47, 1, ' ');
354     EXPECT_NE(CharTypeface, nullptr);
355     OH_Drawing_TypefaceDestroy(CharTypeface);
356 
357     OH_Drawing_FontMgrDestroy(mgr);
358 }
359 
360 /*
361 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0400
362 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight100
363 * @tc.desc: Test for matching font typeface with weight 100.
364 * @tc.size: MediumTest
365 * @tc.type: Function
366 * @tc.level: Level 0
367 */
368 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight100, Function | MediumTest | Level1)
369 {
370     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
371     EXPECT_NE(mgr, nullptr);
372 
373     const char* matchFamilyName = "HarmonyOS-Sans";
374     OH_Drawing_FontStyleStruct normalStyle;
375     normalStyle.weight = FONT_WEIGHT_100;
376     normalStyle.width = FONT_WIDTH_NORMAL;
377     normalStyle.slant = FONT_STYLE_NORMAL;
378 
379     const char *bcp47[] = {"zh-Hans", "zh-CN"};
380     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
381                                                                                     normalStyle, bcp47, 1, ' ');
382     EXPECT_NE(CharTypeface, nullptr);
383     OH_Drawing_TypefaceDestroy(CharTypeface);
384 
385     OH_Drawing_FontMgrDestroy(mgr);
386 }
387 
388 /*
389 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0500
390 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth1
391 * @tc.desc: Test for matching font typeface with width 1.
392 * @tc.size: MediumTest
393 * @tc.type: Function
394 * @tc.level: Level 0
395 */
396 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth1, Function | MediumTest | Level1)
397 {
398     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
399     EXPECT_NE(mgr, nullptr);
400 
401     const char* matchFamilyName = "HarmonyOS-Sans";
402     OH_Drawing_FontStyleStruct normalStyle;
403     normalStyle.weight = FONT_WEIGHT_100;
404     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
405     normalStyle.slant = FONT_STYLE_NORMAL;
406 
407     const char *bcp47[] = {"zh-Hans", "zh-CN"};
408     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
409                                                                                     normalStyle, bcp47, 1, ' ');
410     EXPECT_NE(CharTypeface, nullptr);
411     OH_Drawing_TypefaceDestroy(CharTypeface);
412 
413     OH_Drawing_FontMgrDestroy(mgr);
414 }
415 
416 /*
417 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0600
418 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth9
419 * @tc.desc: Test for matching font typeface with width 9.
420 * @tc.size: MediumTest
421 * @tc.type: Function
422 * @tc.level: Level 0
423 */
424 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth9, Function | MediumTest | Level1)
425 {
426     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
427     EXPECT_NE(mgr, nullptr);
428 
429     const char* matchFamilyName = "HarmonyOS-Sans";
430     OH_Drawing_FontStyleStruct normalStyle;
431     normalStyle.weight = FONT_WEIGHT_100;
432     normalStyle.width = FONT_WIDTH_ULTRA_EXPANDED;
433     normalStyle.slant = FONT_STYLE_NORMAL;
434 
435     const char *bcp47[] = {"zh-Hans", "zh-CN"};
436     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
437                                                                                     normalStyle, bcp47, 1, ' ');
438     EXPECT_NE(CharTypeface, nullptr);
439     OH_Drawing_TypefaceDestroy(CharTypeface);
440 
441     OH_Drawing_FontMgrDestroy(mgr);
442 }
443 
444 /*
445 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0700
446 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterStyleOblique
447 * @tc.desc: Test for matching font typeface with style oblique.
448 * @tc.size: MediumTest
449 * @tc.type: Function
450 * @tc.level: Level 0
451 */
452 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterStyleOblique,
453     Function | MediumTest | Level1)
454 {
455     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
456     EXPECT_NE(mgr, nullptr);
457 
458     const char* matchFamilyName = "HarmonyOS-Sans";
459     OH_Drawing_FontStyleStruct normalStyle;
460     normalStyle.weight = FONT_WEIGHT_100;
461     normalStyle.width = FONT_WIDTH_ULTRA_EXPANDED;
462     normalStyle.slant = FONT_STYLE_OBLIQUE;
463 
464     const char *bcp47[] = {"zh-Hans", "zh-CN"};
465     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
466                                                                                     normalStyle, bcp47, 1, ' ');
467     EXPECT_NE(CharTypeface, nullptr);
468     OH_Drawing_TypefaceDestroy(CharTypeface);
469 
470     OH_Drawing_FontMgrDestroy(mgr);
471 }
472 
473 /*
474 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0800
475 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterFamilyNameNull
476 * @tc.desc: Test for matching font typeface with familyName null.
477 * @tc.size: MediumTest
478 * @tc.type: Function
479 * @tc.level: Level 0
480 */
481 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterFamilyNameNull,
482     Function | MediumTest | Level1)
483 {
484     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
485     EXPECT_NE(mgr, nullptr);
486 
487     const char* matchFamilyName = nullptr;
488     OH_Drawing_FontStyleStruct normalStyle;
489     normalStyle.weight = FONT_WEIGHT_100;
490     normalStyle.width = FONT_WIDTH_ULTRA_EXPANDED;
491     normalStyle.slant = FONT_STYLE_OBLIQUE;
492 
493     const char *bcp47[] = {"zh-Hans", "zh-CN"};
494     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
495                                                                                     normalStyle, bcp47, 1, ' ');
496     EXPECT_NE(CharTypeface, nullptr);
497     OH_Drawing_TypefaceDestroy(CharTypeface);
498 
499     OH_Drawing_FontMgrDestroy(mgr);
500 }
501 
502 /*
503 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0900
504 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterFamilyWeightExceedMaxValue
505 * @tc.desc: Test for matching font typeface with familyName null.
506 * @tc.size: MediumTest
507 * @tc.type: Function
508 * @tc.level: Level 0
509 */
510 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterFamilyWeightExceedMaxValue,
511  TestSize.Level1)
512 {
513     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
514     EXPECT_NE(mgr, nullptr);
515 
516     const char* matchFamilyName = nullptr;
517     OH_Drawing_FontStyleStruct abnormalStyle;
518     abnormalStyle.weight = OH_Drawing_FontWeight(99); // exceeding the defined max value
519     abnormalStyle.width = FONT_WIDTH_ULTRA_EXPANDED;
520     abnormalStyle.slant = FONT_STYLE_OBLIQUE;
521 
522     const char *bcp47[] = {"zh-Hans", "zh-CN"};
523     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
524                                                                                     abnormalStyle, bcp47, 1, ' ');
525     EXPECT_NE(CharTypeface, nullptr);
526     OH_Drawing_TypefaceDestroy(CharTypeface);
527 
528     OH_Drawing_FontMgrDestroy(mgr);
529 }
530 
531 /*
532 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_0900
533 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterFamilyWeightExceedMaxValue
534 * @tc.desc: Test for matching font typeface with familyName null.
535 * @tc.size: MediumTest
536 * @tc.type: Function
537 * @tc.level: Level 0
538 */
539 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterFamilyWidthExceedMaxValue,
540  TestSize.Level1)
541 {
542     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
543     EXPECT_NE(mgr, nullptr);
544 
545     const char* matchFamilyName = nullptr;
546     OH_Drawing_FontStyleStruct abnormalStyle;
547     abnormalStyle.weight = FONT_WEIGHT_100; // exceeding the defined max value
548     abnormalStyle.width = OH_Drawing_FontWidth(99);
549     abnormalStyle.slant = FONT_STYLE_OBLIQUE;
550 
551     const char *bcp47[] = {"zh-Hans", "zh-CN"};
552     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
553                                                                                     abnormalStyle, bcp47, 1, ' ');
554     EXPECT_NE(CharTypeface, nullptr);
555     OH_Drawing_TypefaceDestroy(CharTypeface);
556 
557     OH_Drawing_FontMgrDestroy(mgr);
558 }
559 
560 /*
561 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1000
562 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200
563 * @tc.desc: Test for matching font typeface with weight 200.
564 * @tc.size: MediumTest
565 * @tc.type: Function
566 * @tc.level: Level 0
567 */
568 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200, Function | MediumTest | Level1)
569 {
570     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
571     EXPECT_NE(mgr, nullptr);
572 
573     const char* matchFamilyName = "HarmonyOS-Sans";
574     OH_Drawing_FontStyleStruct normalStyle;
575     normalStyle.weight = FONT_WEIGHT_200;
576     normalStyle.width = FONT_WIDTH_NORMAL;
577     normalStyle.slant = FONT_STYLE_NORMAL;
578 
579     const char *bcp47[] = {"zh-Hans", "zh-CN"};
580     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
581                                                                                     normalStyle, bcp47, 1, ' ');
582     EXPECT_NE(CharTypeface, nullptr);
583     OH_Drawing_TypefaceDestroy(CharTypeface);
584 
585     OH_Drawing_FontMgrDestroy(mgr);
586 }
587 
588 /*
589 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1100
590 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300
591 * @tc.desc: Test for matching font typeface with weight 300.
592 * @tc.size: MediumTest
593 * @tc.type: Function
594 * @tc.level: Level 0
595 */
596 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300, Function | MediumTest | Level1)
597 {
598     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
599     EXPECT_NE(mgr, nullptr);
600 
601     const char* matchFamilyName = "HarmonyOS-Sans";
602     OH_Drawing_FontStyleStruct normalStyle;
603     normalStyle.weight = FONT_WEIGHT_300;
604     normalStyle.width = FONT_WIDTH_NORMAL;
605     normalStyle.slant = FONT_STYLE_NORMAL;
606 
607     const char *bcp47[] = {"zh-Hans", "zh-CN"};
608     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
609                                                                                     normalStyle, bcp47, 1, ' ');
610     EXPECT_NE(CharTypeface, nullptr);
611     OH_Drawing_TypefaceDestroy(CharTypeface);
612 
613     OH_Drawing_FontMgrDestroy(mgr);
614 }
615 
616 /*
617 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1200
618 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight400
619 * @tc.desc: Test for matching font typeface with weight 400.
620 * @tc.size: MediumTest
621 * @tc.type: Function
622 * @tc.level: Level 0
623 */
624 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight400, Function | MediumTest | Level1)
625 {
626     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
627     EXPECT_NE(mgr, nullptr);
628 
629     const char* matchFamilyName = "HarmonyOS-Sans";
630     OH_Drawing_FontStyleStruct normalStyle;
631     normalStyle.weight = FONT_WEIGHT_400;
632     normalStyle.width = FONT_WIDTH_NORMAL;
633     normalStyle.slant = FONT_STYLE_NORMAL;
634 
635     const char *bcp47[] = {"zh-Hans", "zh-CN"};
636     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
637                                                                                     normalStyle, bcp47, 1, ' ');
638     EXPECT_NE(CharTypeface, nullptr);
639     OH_Drawing_TypefaceDestroy(CharTypeface);
640 
641     OH_Drawing_FontMgrDestroy(mgr);
642 }
643 
644 /*
645 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1300
646 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight500
647 * @tc.desc: Test for matching font typeface with weight 500.
648 * @tc.size: MediumTest
649 * @tc.type: Function
650 * @tc.level: Level 0
651 */
652 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight500, Function | MediumTest | Level1)
653 {
654     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
655     EXPECT_NE(mgr, nullptr);
656 
657     const char* matchFamilyName = "HarmonyOS-Sans";
658     OH_Drawing_FontStyleStruct normalStyle;
659     normalStyle.weight = FONT_WEIGHT_500;
660     normalStyle.width = FONT_WIDTH_NORMAL;
661     normalStyle.slant = FONT_STYLE_NORMAL;
662 
663     const char *bcp47[] = {"zh-Hans", "zh-CN"};
664     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
665                                                                                     normalStyle, bcp47, 1, ' ');
666     EXPECT_NE(CharTypeface, nullptr);
667     OH_Drawing_TypefaceDestroy(CharTypeface);
668 
669     OH_Drawing_FontMgrDestroy(mgr);
670 }
671 
672 /*
673 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1400
674 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight600
675 * @tc.desc: Test for matching font typeface with weight 600.
676 * @tc.size: MediumTest
677 * @tc.type: Function
678 * @tc.level: Level 0
679 */
680 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight600, Function | MediumTest | Level1)
681 {
682     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
683     EXPECT_NE(mgr, nullptr);
684 
685     const char* matchFamilyName = "HarmonyOS-Sans";
686     OH_Drawing_FontStyleStruct normalStyle;
687     normalStyle.weight = FONT_WEIGHT_600;
688     normalStyle.width = FONT_WIDTH_NORMAL;
689     normalStyle.slant = FONT_STYLE_NORMAL;
690 
691     const char *bcp47[] = {"zh-Hans", "zh-CN"};
692     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
693                                                                                     normalStyle, bcp47, 1, ' ');
694     EXPECT_NE(CharTypeface, nullptr);
695     OH_Drawing_TypefaceDestroy(CharTypeface);
696 
697     OH_Drawing_FontMgrDestroy(mgr);
698 }
699 
700 /*
701 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1500
702 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight700
703 * @tc.desc: Test for matching font typeface with weight 700.
704 * @tc.size: MediumTest
705 * @tc.type: Function
706 * @tc.level: Level 0
707 */
708 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight700, Function | MediumTest | Level1)
709 {
710     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
711     EXPECT_NE(mgr, nullptr);
712 
713     const char* matchFamilyName = "HarmonyOS-Sans";
714     OH_Drawing_FontStyleStruct normalStyle;
715     normalStyle.weight = FONT_WEIGHT_700;
716     normalStyle.width = FONT_WIDTH_NORMAL;
717     normalStyle.slant = FONT_STYLE_NORMAL;
718 
719     const char *bcp47[] = {"zh-Hans", "zh-CN"};
720     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
721                                                                                     normalStyle, bcp47, 1, ' ');
722     EXPECT_NE(CharTypeface, nullptr);
723     OH_Drawing_TypefaceDestroy(CharTypeface);
724 
725     OH_Drawing_FontMgrDestroy(mgr);
726 }
727 
728 /*
729 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1600
730 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight800
731 * @tc.desc: Test for matching font typeface with weight 800.
732 * @tc.size: MediumTest
733 * @tc.type: Function
734 * @tc.level: Level 0
735 */
736 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight800, Function | MediumTest | Level1)
737 {
738     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
739     EXPECT_NE(mgr, nullptr);
740 
741     const char* matchFamilyName = "HarmonyOS-Sans";
742     OH_Drawing_FontStyleStruct normalStyle;
743     normalStyle.weight = FONT_WEIGHT_800;
744     normalStyle.width = FONT_WIDTH_NORMAL;
745     normalStyle.slant = FONT_STYLE_NORMAL;
746 
747     const char *bcp47[] = {"zh-Hans", "zh-CN"};
748     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
749                                                                                     normalStyle, bcp47, 1, ' ');
750     EXPECT_NE(CharTypeface, nullptr);
751     OH_Drawing_TypefaceDestroy(CharTypeface);
752 
753     OH_Drawing_FontMgrDestroy(mgr);
754 }
755 
756 /*
757 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1700
758 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Width1
759 * @tc.desc: Test for matching font typeface with width 1.
760 * @tc.size: MediumTest
761 * @tc.type: Function
762 * @tc.level: Level 0
763 */
764 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Width1,
765     Function | MediumTest | Level1)
766 {
767     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
768     EXPECT_NE(mgr, nullptr);
769 
770     const char* matchFamilyName = "HarmonyOS-Sans";
771     OH_Drawing_FontStyleStruct normalStyle;
772     normalStyle.weight = FONT_WEIGHT_200;
773     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
774     normalStyle.slant = FONT_STYLE_NORMAL;
775 
776     const char *bcp47[] = {"zh-Hans", "zh-CN"};
777     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
778                                                                                     normalStyle, bcp47, 1, ' ');
779     EXPECT_NE(CharTypeface, nullptr);
780     OH_Drawing_TypefaceDestroy(CharTypeface);
781 
782     OH_Drawing_FontMgrDestroy(mgr);
783 }
784 
785 /*
786 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1800
787 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth2
788 * @tc.desc: Test for matching font typeface with width 2.
789 * @tc.size: MediumTest
790 * @tc.type: Function
791 * @tc.level: Level 0
792 */
793 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth2, Function | MediumTest | Level1)
794 {
795     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
796     EXPECT_NE(mgr, nullptr);
797 
798     const char* matchFamilyName = "HarmonyOS-Sans";
799     OH_Drawing_FontStyleStruct normalStyle;
800     normalStyle.weight = FONT_WEIGHT_100;
801     normalStyle.width = FONT_WIDTH_EXTRA_CONDENSED;
802     normalStyle.slant = FONT_STYLE_NORMAL;
803 
804     const char *bcp47[] = {"zh-Hans", "zh-CN"};
805     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
806                                                                                     normalStyle, bcp47, 1, ' ');
807     EXPECT_NE(CharTypeface, nullptr);
808     OH_Drawing_TypefaceDestroy(CharTypeface);
809 
810     OH_Drawing_FontMgrDestroy(mgr);
811 }
812 
813 /*
814 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_1900
815 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth3
816 * @tc.desc: Test for matching font typeface with width 3.
817 * @tc.size: MediumTest
818 * @tc.type: Function
819 * @tc.level: Level 0
820 */
821 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth3, Function | MediumTest | Level1)
822 {
823     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
824     EXPECT_NE(mgr, nullptr);
825 
826     const char* matchFamilyName = "HarmonyOS-Sans";
827     OH_Drawing_FontStyleStruct normalStyle;
828     normalStyle.weight = FONT_WEIGHT_100;
829     normalStyle.width = FONT_WIDTH_CONDENSED;
830     normalStyle.slant = FONT_STYLE_NORMAL;
831 
832     const char *bcp47[] = {"zh-Hans", "zh-CN"};
833     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
834                                                                                     normalStyle, bcp47, 1, ' ');
835     EXPECT_NE(CharTypeface, nullptr);
836     OH_Drawing_TypefaceDestroy(CharTypeface);
837 
838     OH_Drawing_FontMgrDestroy(mgr);
839 }
840 
841 /*
842 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2000
843 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth4
844 * @tc.desc: Test for matching font typeface with width 4.
845 * @tc.size: MediumTest
846 * @tc.type: Function
847 * @tc.level: Level 0
848 */
849 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth4, Function | MediumTest | Level1)
850 {
851     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
852     EXPECT_NE(mgr, nullptr);
853 
854     const char* matchFamilyName = "HarmonyOS-Sans";
855     OH_Drawing_FontStyleStruct normalStyle;
856     normalStyle.weight = FONT_WEIGHT_100;
857     normalStyle.width = FONT_WIDTH_SEMI_CONDENSED;
858     normalStyle.slant = FONT_STYLE_NORMAL;
859 
860     const char *bcp47[] = {"zh-Hans", "zh-CN"};
861     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
862                                                                                     normalStyle, bcp47, 1, ' ');
863     EXPECT_NE(CharTypeface, nullptr);
864     OH_Drawing_TypefaceDestroy(CharTypeface);
865 
866     OH_Drawing_FontMgrDestroy(mgr);
867 }
868 
869 /*
870 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2100
871 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth6
872 * @tc.desc: Test for matching font typeface with width 6.
873 * @tc.size: MediumTest
874 * @tc.type: Function
875 * @tc.level: Level 0
876 */
877 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth6, Function | MediumTest | Level1)
878 {
879     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
880     EXPECT_NE(mgr, nullptr);
881 
882     const char* matchFamilyName = "HarmonyOS-Sans";
883     OH_Drawing_FontStyleStruct normalStyle;
884     normalStyle.weight = FONT_WEIGHT_100;
885     normalStyle.width = FONT_WIDTH_SEMI_EXPANDED;
886     normalStyle.slant = FONT_STYLE_NORMAL;
887 
888     const char *bcp47[] = {"zh-Hans", "zh-CN"};
889     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
890                                                                                     normalStyle, bcp47, 1, ' ');
891     EXPECT_NE(CharTypeface, nullptr);
892     OH_Drawing_TypefaceDestroy(CharTypeface);
893 
894     OH_Drawing_FontMgrDestroy(mgr);
895 }
896 
897 /*
898 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2200
899 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth7
900 * @tc.desc: Test for matching font typeface with width 7.
901 * @tc.size: MediumTest
902 * @tc.type: Function
903 * @tc.level: Level 0
904 */
905 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth7, Function | MediumTest | Level1)
906 {
907     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
908     EXPECT_NE(mgr, nullptr);
909 
910     const char* matchFamilyName = "HarmonyOS-Sans";
911     OH_Drawing_FontStyleStruct normalStyle;
912     normalStyle.weight = FONT_WEIGHT_100;
913     normalStyle.width = FONT_WIDTH_EXPANDED;
914     normalStyle.slant = FONT_STYLE_NORMAL;
915 
916     const char *bcp47[] = {"zh-Hans", "zh-CN"};
917     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
918                                                                                     normalStyle, bcp47, 1, ' ');
919     EXPECT_NE(CharTypeface, nullptr);
920     OH_Drawing_TypefaceDestroy(CharTypeface);
921 
922     OH_Drawing_FontMgrDestroy(mgr);
923 }
924 
925 /*
926 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2300
927 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWidth8
928 * @tc.desc: Test for matching font typeface with width 8.
929 * @tc.size: MediumTest
930 * @tc.type: Function
931 * @tc.level: Level 0
932 */
933 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWidth8, Function | MediumTest | Level1)
934 {
935     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
936     EXPECT_NE(mgr, nullptr);
937 
938     const char* matchFamilyName = "HarmonyOS-Sans";
939     OH_Drawing_FontStyleStruct normalStyle;
940     normalStyle.weight = FONT_WEIGHT_100;
941     normalStyle.width = FONT_WIDTH_EXTRA_EXPANDED;
942     normalStyle.slant = FONT_STYLE_NORMAL;
943 
944     const char *bcp47[] = {"zh-Hans", "zh-CN"};
945     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
946                                                                                     normalStyle, bcp47, 1, ' ');
947     EXPECT_NE(CharTypeface, nullptr);
948     OH_Drawing_TypefaceDestroy(CharTypeface);
949 
950     OH_Drawing_FontMgrDestroy(mgr);
951 }
952 
953 /*
954 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2400
955 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Width9
956 * @tc.desc: Test for matching font typeface with width 9.
957 * @tc.size: MediumTest
958 * @tc.type: Function
959 * @tc.level: Level 0
960 */
961 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Width9,
962     Function | MediumTest | Level1)
963 {
964     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
965     EXPECT_NE(mgr, nullptr);
966 
967     const char* matchFamilyName = "HarmonyOS-Sans";
968     OH_Drawing_FontStyleStruct normalStyle;
969     normalStyle.weight = FONT_WEIGHT_200;
970     normalStyle.width = FONT_WIDTH_ULTRA_EXPANDED;
971     normalStyle.slant = FONT_STYLE_NORMAL;
972 
973     const char *bcp47[] = {"zh-Hans", "zh-CN"};
974     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
975                                                                                     normalStyle, bcp47, 1, ' ');
976     EXPECT_NE(CharTypeface, nullptr);
977     OH_Drawing_TypefaceDestroy(CharTypeface);
978 
979     OH_Drawing_FontMgrDestroy(mgr);
980 }
981 
982 /*
983 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2500
984 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterStyle0
985 * @tc.desc: Test for matching font typeface with style 0.
986 * @tc.size: MediumTest
987 * @tc.type: Function
988 * @tc.level: Level 0
989 */
990 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterStyle0, Function | MediumTest | Level1)
991 {
992     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
993     EXPECT_NE(mgr, nullptr);
994 
995     const char* matchFamilyName = "HarmonyOS-Sans";
996     OH_Drawing_FontStyleStruct normalStyle;
997     normalStyle.weight = FONT_WEIGHT_100;
998     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
999     normalStyle.slant = FONT_STYLE_NORMAL;
1000 
1001     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1002     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1003                                                                                     normalStyle, bcp47, 1, ' ');
1004     EXPECT_NE(CharTypeface, nullptr);
1005     OH_Drawing_TypefaceDestroy(CharTypeface);
1006 
1007     OH_Drawing_FontMgrDestroy(mgr);
1008 }
1009 
1010 /*
1011 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2600
1012 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterStyle1
1013 * @tc.desc: Test for matching font typeface with style 1.
1014 * @tc.size: MediumTest
1015 * @tc.type: Function
1016 * @tc.level: Level 0
1017 */
1018 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterStyle1, Function | MediumTest | Level1)
1019 {
1020     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1021     EXPECT_NE(mgr, nullptr);
1022 
1023     const char* matchFamilyName = "HarmonyOS-Sans";
1024     OH_Drawing_FontStyleStruct normalStyle;
1025     normalStyle.weight = FONT_WEIGHT_100;
1026     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1027     normalStyle.slant = FONT_STYLE_ITALIC;
1028 
1029     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1030     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1031                                                                                     normalStyle, bcp47, 1, ' ');
1032     EXPECT_NE(CharTypeface, nullptr);
1033     OH_Drawing_TypefaceDestroy(CharTypeface);
1034 
1035     OH_Drawing_FontMgrDestroy(mgr);
1036 }
1037 
1038 /*
1039 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2700
1040 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterStyle2
1041 * @tc.desc: Test for matching font typeface with style 2.
1042 * @tc.size: MediumTest
1043 * @tc.type: Function
1044 * @tc.level: Level 0
1045 */
1046 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterStyle2, Function | MediumTest | Level1)
1047 {
1048     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1049     EXPECT_NE(mgr, nullptr);
1050 
1051     const char* matchFamilyName = "HarmonyOS-Sans";
1052     OH_Drawing_FontStyleStruct normalStyle;
1053     normalStyle.weight = FONT_WEIGHT_100;
1054     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1055     normalStyle.slant = FONT_STYLE_OBLIQUE;
1056 
1057     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1058     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1059                                                                                     normalStyle, bcp47, 1, ' ');
1060     EXPECT_NE(CharTypeface, nullptr);
1061     OH_Drawing_TypefaceDestroy(CharTypeface);
1062 
1063     OH_Drawing_FontMgrDestroy(mgr);
1064 }
1065 
1066 /*
1067 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2800
1068 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Style0
1069 * @tc.desc: Test for matching font typeface with weight 200 and style 0.
1070 * @tc.size: MediumTest
1071 * @tc.type: Function
1072 * @tc.level: Level 0
1073 */
1074 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Style0,
1075     Function | MediumTest | Level1)
1076 {
1077     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1078     EXPECT_NE(mgr, nullptr);
1079 
1080     const char* matchFamilyName = "HarmonyOS-Sans";
1081     OH_Drawing_FontStyleStruct normalStyle;
1082     normalStyle.weight = FONT_WEIGHT_200;
1083     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1084     normalStyle.slant = FONT_STYLE_NORMAL;
1085 
1086     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1087     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1088                                                                                     normalStyle, bcp47, 1, ' ');
1089     EXPECT_NE(CharTypeface, nullptr);
1090     OH_Drawing_TypefaceDestroy(CharTypeface);
1091 
1092     OH_Drawing_FontMgrDestroy(mgr);
1093 }
1094 
1095 /*
1096 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2900
1097 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Style1
1098 * @tc.desc: Test for matching font typeface with weight 200 and style 1.
1099 * @tc.size: MediumTest
1100 * @tc.type: Function
1101 * @tc.level: Level 0
1102 */
1103 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Style1,
1104     Function | MediumTest | Level1)
1105 {
1106     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1107     EXPECT_NE(mgr, nullptr);
1108 
1109     const char* matchFamilyName = "HarmonyOS-Sans";
1110     OH_Drawing_FontStyleStruct normalStyle;
1111     normalStyle.weight = FONT_WEIGHT_200;
1112     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1113     normalStyle.slant = FONT_STYLE_ITALIC;
1114 
1115     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1116     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1117                                                                                     normalStyle, bcp47, 1, ' ');
1118     EXPECT_NE(CharTypeface, nullptr);
1119     OH_Drawing_TypefaceDestroy(CharTypeface);
1120 
1121     OH_Drawing_FontMgrDestroy(mgr);
1122 }
1123 
1124 /*
1125 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_3000
1126 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Style2
1127 * @tc.desc: Test for matching font typeface with weight 200 and style 2.
1128 * @tc.size: MediumTest
1129 * @tc.type: Function
1130 * @tc.level: Level 0
1131 */
1132 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight200Style2,
1133     Function | MediumTest | Level1)
1134 {
1135     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1136     EXPECT_NE(mgr, nullptr);
1137 
1138     const char* matchFamilyName = "HarmonyOS-Sans";
1139     OH_Drawing_FontStyleStruct normalStyle;
1140     normalStyle.weight = FONT_WEIGHT_300;
1141     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1142     normalStyle.slant = FONT_STYLE_OBLIQUE;
1143 
1144     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1145     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1146                                                                                     normalStyle, bcp47, 1, ' ');
1147     EXPECT_NE(CharTypeface, nullptr);
1148     OH_Drawing_TypefaceDestroy(CharTypeface);
1149 
1150     OH_Drawing_FontMgrDestroy(mgr);
1151 }
1152 
1153 /*
1154 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_3100
1155 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300Style0
1156 * @tc.desc: Test for matching font typeface with weight 300 and style 0.
1157 * @tc.size: MediumTest
1158 * @tc.type: Function
1159 * @tc.level: Level 0
1160 */
1161 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300Style0,
1162     Function | MediumTest | Level1)
1163 {
1164     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1165     EXPECT_NE(mgr, nullptr);
1166 
1167     const char* matchFamilyName = "HarmonyOS-Sans";
1168     OH_Drawing_FontStyleStruct normalStyle;
1169     normalStyle.weight = FONT_WEIGHT_300;
1170     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1171     normalStyle.slant = FONT_STYLE_NORMAL;
1172 
1173     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1174     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1175                                                                                     normalStyle, bcp47, 1, ' ');
1176     EXPECT_NE(CharTypeface, nullptr);
1177     OH_Drawing_TypefaceDestroy(CharTypeface);
1178 
1179     OH_Drawing_FontMgrDestroy(mgr);
1180 }
1181 
1182 /*
1183 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_2900
1184 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300Style1
1185 * @tc.desc: Test for matching font typeface with weight 300 and style 1.
1186 * @tc.size: MediumTest
1187 * @tc.type: Function
1188 * @tc.level: Level 0
1189 */
1190 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300Style1,
1191     Function | MediumTest | Level1)
1192 {
1193     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1194     EXPECT_NE(mgr, nullptr);
1195 
1196     const char* matchFamilyName = "HarmonyOS-Sans";
1197     OH_Drawing_FontStyleStruct normalStyle;
1198     normalStyle.weight = FONT_WEIGHT_300;
1199     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1200     normalStyle.slant = FONT_STYLE_ITALIC;
1201 
1202     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1203     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1204                                                                                     normalStyle, bcp47, 1, ' ');
1205     EXPECT_NE(CharTypeface, nullptr);
1206     OH_Drawing_TypefaceDestroy(CharTypeface);
1207 
1208     OH_Drawing_FontMgrDestroy(mgr);
1209 }
1210 
1211 /*
1212 * @tc.number: SUB_GRAPHIC_NAPI_OH_Drawing_FontMgrMatchFamilyStyleCharacter_3000
1213 * @tc.name: testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300Style2
1214 * @tc.desc: Test for matching font typeface with weight 300 and style 2.
1215 * @tc.size: MediumTest
1216 * @tc.type: Function
1217 * @tc.level: Level 0
1218 */
1219 HWTEST_F(OH_Drawing_FontMgrTest, testOHDrawingFontMgrMatchFamilyStyleCharacterWeight300Style2,
1220     Function | MediumTest | Level1)
1221 {
1222     OH_Drawing_FontMgr *mgr = OH_Drawing_FontMgrCreate();
1223     EXPECT_NE(mgr, nullptr);
1224 
1225     const char* matchFamilyName = "HarmonyOS-Sans";
1226     OH_Drawing_FontStyleStruct normalStyle;
1227     normalStyle.weight = FONT_WEIGHT_300;
1228     normalStyle.width = FONT_WIDTH_ULTRA_CONDENSED;
1229     normalStyle.slant = FONT_STYLE_OBLIQUE;
1230 
1231     const char *bcp47[] = {"zh-Hans", "zh-CN"};
1232     OH_Drawing_Typeface *CharTypeface = OH_Drawing_FontMgrMatchFamilyStyleCharacter(mgr, matchFamilyName,
1233                                                                                     normalStyle, bcp47, 1, ' ');
1234     EXPECT_NE(CharTypeface, nullptr);
1235     OH_Drawing_TypefaceDestroy(CharTypeface);
1236 
1237     OH_Drawing_FontMgrDestroy(mgr);
1238 }
1239 
1240 } // namespace Drawing
1241 } // namespace Rosen
1242 } // namespace OHOS