1 /*
2  * Copyright (c) 2022-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 #include "gtest/gtest.h"
17 #include "drawing_bitmap.h"
18 #include "drawing_brush.h"
19 #include "drawing_canvas.h"
20 #include "drawing_color.h"
21 #include "drawing_font.h"
22 #include "drawing_font_collection.h"
23 #include "drawing_path.h"
24 #include "drawing_pen.h"
25 #include "drawing_point.h"
26 #include "drawing_text_declaration.h"
27 #include "drawing_text_typography.h"
28 #ifndef USE_GRAPHIC_TEXT_GINE
29 #include "rosen_text/ui/typography.h"
30 #include "rosen_text/ui/typography_create.h"
31 #else
32 #include "rosen_text/typography.h"
33 #include "rosen_text/typography_create.h"
34 #endif
35 
36 #include <string>
37 #include <fstream>
38 
39 #ifndef USE_GRAPHIC_TEXT_GINE
40 using namespace rosen;
41 #else
42 using namespace OHOS::Rosen;
43 #endif
44 using namespace testing;
45 using namespace testing::ext;
46 
47 namespace OHOS {
48 namespace {
49 const double LEFT_POS = 50.0;
50 const double RIGHT_POS = 150.0;
51 const double ARC_FONT_SIZE = 30;
52 const double MAX_WIDTH = 800.0;
53 const double SWEEP_DEGREE = 180.0;
54 } // namespace
55 
56 class OH_Drawing_TypographyTest : public testing::Test {
57 };
58 
ConvertToOriginalText(OH_Drawing_TypographyStyle * style)59 static TypographyStyle* ConvertToOriginalText(OH_Drawing_TypographyStyle* style)
60 {
61     return reinterpret_cast<TypographyStyle*>(style);
62 }
63 
ConvertToOriginalText(OH_Drawing_TextStyle * style)64 static TextStyle* ConvertToOriginalText(OH_Drawing_TextStyle* style)
65 {
66     return reinterpret_cast<TextStyle*>(style);
67 }
68 
69 /*
70  * @tc.name: OH_Drawing_TypographyTest001
71  * @tc.desc: test for creating TypographyStyle
72  * @tc.type: FUNC
73  */
74 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest001, TestSize.Level1)
75 {
76     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
77     EXPECT_EQ(typoStyle == nullptr, false);
78     OH_Drawing_DestroyTypographyStyle(typoStyle);
79 }
80 
81 /*
82  * @tc.name: OH_Drawing_TypographyTest002
83  * @tc.desc: test for text direction
84  * @tc.type: FUNC
85  */
86 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest002, TestSize.Level1)
87 {
88     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
89     OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_LTR);
90 #ifndef USE_GRAPHIC_TEXT_GINE
91     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection_, TextDirection::LTR);
92 #else
93     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::LTR);
94 #endif
95     OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_RTL);
96 #ifndef USE_GRAPHIC_TEXT_GINE
97     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection_, TextDirection::RTL);
98 #else
99     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::RTL);
100 #endif
101     OH_Drawing_SetTypographyTextDirection(typoStyle, -1);
102 #ifndef USE_GRAPHIC_TEXT_GINE
103     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection_, TextDirection::LTR);
104 #else
105     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::LTR);
106 #endif
107 }
108 
109 /*
110  * @tc.name: OH_Drawing_TypographyTest003
111  * @tc.desc: test for text alignment
112  * @tc.type: FUNC
113  */
114 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest003, TestSize.Level1)
115 {
116     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
117     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_LEFT);
118 #ifndef USE_GRAPHIC_TEXT_GINE
119     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::LEFT);
120 #else
121     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::LEFT);
122 #endif
123     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_RIGHT);
124 #ifndef USE_GRAPHIC_TEXT_GINE
125     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::RIGHT);
126 #else
127     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::RIGHT);
128 #endif
129     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_CENTER);
130 #ifndef USE_GRAPHIC_TEXT_GINE
131     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::CENTER);
132 #else
133     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::CENTER);
134 #endif
135     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_JUSTIFY);
136 #ifndef USE_GRAPHIC_TEXT_GINE
137     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::JUSTIFY);
138 #else
139     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::JUSTIFY);
140 #endif
141     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_START);
142 #ifndef USE_GRAPHIC_TEXT_GINE
143     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::START);
144 #else
145     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::START);
146 #endif
147     OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_END);
148 #ifndef USE_GRAPHIC_TEXT_GINE
149     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::END);
150 #else
151     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::END);
152 #endif
153     OH_Drawing_SetTypographyTextAlign(typoStyle, -1);
154 #ifndef USE_GRAPHIC_TEXT_GINE
155     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::LEFT);
156 #else
157     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::LEFT);
158 #endif
159 }
160 
161 /*
162  * @tc.name: OH_Drawing_TypographyTest004
163  * @tc.desc: test for max lines
164  * @tc.type: FUNC
165  */
166 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest004, TestSize.Level1)
167 {
168     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
169     OH_Drawing_SetTypographyTextMaxLines(typoStyle, 100);
170 #ifndef USE_GRAPHIC_TEXT_GINE
171     EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines_, 100);
172 #else
173     EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines, 100);
174 #endif
175     OH_Drawing_SetTypographyTextMaxLines(typoStyle, 200);
176 #ifndef USE_GRAPHIC_TEXT_GINE
177     EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines_, 200);
178 #else
179     EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines, 200);
180 #endif
181 }
182 
183 /*
184  * @tc.name: OH_Drawing_TypographyTest005
185  * @tc.desc: test for creating text style
186  * @tc.type: FUNC
187  */
188 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest005, TestSize.Level1)
189 {
190     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
191     EXPECT_EQ(txtStyle == nullptr, false);
192     OH_Drawing_DestroyTextStyle(txtStyle);
193 }
194 
195 /*
196  * @tc.name: OH_Drawing_TypographyTest006
197  * @tc.desc: test for text color
198  * @tc.type: FUNC
199  */
200 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest006, TestSize.Level1)
201 {
202     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
203     // black
204     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
205 #ifndef USE_GRAPHIC_TEXT_GINE
206     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color_, 0xFF000000);
207 #else
208     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFF000000);
209 #endif
210     // red
211     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00));
212 #ifndef USE_GRAPHIC_TEXT_GINE
213     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color_, 0xFFFF0000);
214 #else
215     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFFFF0000);
216 #endif
217     // blue
218     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0xFF));
219 #ifndef USE_GRAPHIC_TEXT_GINE
220     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color_, 0xFF0000FF);
221 #else
222     EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFF0000FF);
223 #endif
224 }
225 
226 /*
227  * @tc.name: OH_Drawing_TypographyTest007
228  * @tc.desc: test for font size
229  * @tc.type: FUNC
230  */
231 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest007, TestSize.Level1)
232 {
233     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
234     OH_Drawing_SetTextStyleFontSize(txtStyle, 80);
235 #ifndef USE_GRAPHIC_TEXT_GINE
236     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize_, 80);
237 #else
238     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize, 80);
239 #endif
240     OH_Drawing_SetTextStyleFontSize(txtStyle, 40);
241 #ifndef USE_GRAPHIC_TEXT_GINE
242     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize_, 40);
243 #else
244     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize, 40);
245 #endif
246 }
247 
248 /*
249  * @tc.name: OH_Drawing_TypographyTest008
250  * @tc.desc: test for font weight
251  * @tc.type: FUNC
252  */
253 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest008, TestSize.Level1)
254 {
255     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
256     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_100);
257 #ifndef USE_GRAPHIC_TEXT_GINE
258     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W100);
259 #else
260     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W100);
261 #endif
262     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_200);
263 #ifndef USE_GRAPHIC_TEXT_GINE
264     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W200);
265 #else
266     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W200);
267 #endif
268     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_300);
269 #ifndef USE_GRAPHIC_TEXT_GINE
270     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W300);
271 #else
272     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W300);
273 #endif
274     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
275 #ifndef USE_GRAPHIC_TEXT_GINE
276     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W400);
277 #else
278     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W400);
279 #endif
280     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_500);
281 #ifndef USE_GRAPHIC_TEXT_GINE
282     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W500);
283 #else
284     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W500);
285 #endif
286     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_600);
287 #ifndef USE_GRAPHIC_TEXT_GINE
288     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W600);
289 #else
290     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W600);
291 #endif
292     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_700);
293 #ifndef USE_GRAPHIC_TEXT_GINE
294     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W700);
295 #else
296     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W700);
297 #endif
298     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_800);
299 #ifndef USE_GRAPHIC_TEXT_GINE
300     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W800);
301 #else
302     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W800);
303 #endif
304     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_900);
305 #ifndef USE_GRAPHIC_TEXT_GINE
306     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W900);
307 #else
308     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W900);
309 #endif
310     OH_Drawing_SetTextStyleFontWeight(txtStyle, -1);
311 #ifndef USE_GRAPHIC_TEXT_GINE
312     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W400);
313 #else
314     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W400);
315 #endif
316 }
317 
318 /*
319  * @tc.name: OH_Drawing_TypographyTest009
320  * @tc.desc: test for baseline location
321  * @tc.type: FUNC
322  */
323 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest009, TestSize.Level1)
324 {
325     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
326     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
327 #ifndef USE_GRAPHIC_TEXT_GINE
328     EXPECT_EQ(ConvertToOriginalText(txtStyle)->textBaseline_, TextBaseline::ALPHABETIC);
329 #else
330     EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::ALPHABETIC);
331 #endif
332     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_IDEOGRAPHIC);
333 #ifndef USE_GRAPHIC_TEXT_GINE
334     EXPECT_EQ(ConvertToOriginalText(txtStyle)->textBaseline_, TextBaseline::IDEOGRAPHIC);
335 #else
336     EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::IDEOGRAPHIC);
337 #endif
338     OH_Drawing_SetTextStyleBaseLine(txtStyle, -1);
339 #ifndef USE_GRAPHIC_TEXT_GINE
340     EXPECT_EQ(ConvertToOriginalText(txtStyle)->textBaseline_, TextBaseline::ALPHABETIC);
341 #else
342     EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::ALPHABETIC);
343 #endif
344 }
345 
346 /*
347  * @tc.name: OH_Drawing_TypographyTest010
348  * @tc.desc: test for text decoration
349  * @tc.type: FUNC
350  */
351 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest010, TestSize.Level1)
352 {
353     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
354     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_NONE);
355 #ifndef USE_GRAPHIC_TEXT_GINE
356     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::NONE);
357 #else
358     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::NONE);
359 #endif
360     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE);
361 #ifndef USE_GRAPHIC_TEXT_GINE
362     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::UNDERLINE);
363 #else
364     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE);
365 #endif
366     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_OVERLINE);
367 #ifndef USE_GRAPHIC_TEXT_GINE
368     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::OVERLINE);
369 #else
370     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::OVERLINE);
371 #endif
372     OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_LINE_THROUGH);
373 #ifndef USE_GRAPHIC_TEXT_GINE
374     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::LINETHROUGH);
375 #else
376     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::LINE_THROUGH);
377 #endif
378     OH_Drawing_SetTextStyleDecoration(txtStyle, -1);
379 #ifndef USE_GRAPHIC_TEXT_GINE
380     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::NONE);
381 #else
382     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::NONE);
383 #endif
384 }
385 
386 /*
387  * @tc.name: OH_Drawing_TypographyTest011
388  * @tc.desc: test for text decoration color
389  * @tc.type: FUNC
390  */
391 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest011, TestSize.Level1)
392 {
393     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
394     OH_Drawing_SetTextStyleDecorationColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
395 #ifndef USE_GRAPHIC_TEXT_GINE
396     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor_, 0xFF000000);
397 #else
398     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor, 0xFF000000);
399 #endif
400     OH_Drawing_SetTextStyleDecorationColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00));
401 #ifndef USE_GRAPHIC_TEXT_GINE
402     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor_, 0xFFFF0000);
403 #else
404     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor, 0xFFFF0000);
405 #endif
406 }
407 
408 /*
409  * @tc.name: OH_Drawing_TypographyTest012
410  * @tc.desc: test for font height
411  * @tc.type: FUNC
412  */
413 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest012, TestSize.Level1)
414 {
415     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
416     OH_Drawing_SetTextStyleFontHeight(txtStyle, 0.0);
417 #ifndef USE_GRAPHIC_TEXT_GINE
418     EXPECT_EQ(ConvertToOriginalText(txtStyle)->height_, 0.0);
419 #else
420     EXPECT_EQ(ConvertToOriginalText(txtStyle)->heightScale, 0.0);
421 #endif
422 }
423 
424 /*
425  * @tc.name: OH_Drawing_TypographyTest013
426  * @tc.desc: test for font families
427  * @tc.type: FUNC
428  */
429 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest013, TestSize.Level1)
430 {
431     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
432     const char* fontFamilies[] = {"Roboto"};
433     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
434     std::vector<std::string> fontFamiliesResult = {"Roboto"};
435 #ifndef USE_GRAPHIC_TEXT_GINE
436     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontFamilies_, fontFamiliesResult);
437 #else
438     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontFamilies, fontFamiliesResult);
439 #endif
440 }
441 
442 /*
443  * @tc.name: OH_Drawing_TypographyTest014
444  * @tc.desc: test for font italic
445  * @tc.type: FUNC
446  */
447 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest014, TestSize.Level1)
448 {
449     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
450     OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_NORMAL);
451 #ifndef USE_GRAPHIC_TEXT_GINE
452     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle_, FontStyle::NORMAL);
453 #else
454     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::NORMAL);
455 #endif
456     OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_ITALIC);
457 #ifndef USE_GRAPHIC_TEXT_GINE
458     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle_, FontStyle::ITALIC);
459 #else
460     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::ITALIC);
461 #endif
462     OH_Drawing_SetTextStyleFontStyle(txtStyle, -1);
463 #ifndef USE_GRAPHIC_TEXT_GINE
464     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle_, FontStyle::NORMAL);
465 #else
466     EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::NORMAL);
467 #endif
468 }
469 
470 /*
471  * @tc.name: OH_Drawing_TypographyTest015
472  * @tc.desc: test for font locale
473  * @tc.type: FUNC
474  */
475 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest015, TestSize.Level1)
476 {
477     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
478     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
479 #ifndef USE_GRAPHIC_TEXT_GINE
480     EXPECT_EQ(ConvertToOriginalText(txtStyle)->locale_, "en");
481 #else
482     EXPECT_EQ(ConvertToOriginalText(txtStyle)->locale, "en");
483 #endif
484 }
485 
486 /*
487  * @tc.name: OH_Drawing_TypographyTest016
488  * @tc.desc: test for typography
489  * @tc.type: FUNC
490  */
491 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest016, TestSize.Level1)
492 {
493     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
494     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
495     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
496         OH_Drawing_CreateFontCollection());
497     EXPECT_TRUE(handler != nullptr);
498 
499     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
500     double fontSize = 30;
501     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
502     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
503     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
504     const char* fontFamilies[] = {"Roboto"};
505     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
506     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
507 
508     const char* text = "OpenHarmony\n";
509     OH_Drawing_TypographyHandlerAddText(handler, text);
510     OH_Drawing_TypographyHandlerPopTextStyle(handler);
511 
512     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
513     const float indents[] = {1.2, 3.4};
514     OH_Drawing_TypographySetIndents(typography, 2, indents);
515     float indent = 3.4;
516     EXPECT_EQ(indent, OH_Drawing_TypographyGetIndentsWithIndex(typography, 1));
517     double maxWidth = 800.0;
518     OH_Drawing_TypographyLayout(typography, maxWidth);
519     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
520     double position[2] = {10.0, 15.0};
521     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
522     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
523     uint32_t width = 20;
524     uint32_t height = 40;
525     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
526     EXPECT_EQ(width, OH_Drawing_BitmapGetWidth(cBitmap));
527     EXPECT_EQ(height, OH_Drawing_BitmapGetHeight(cBitmap));
528 
529     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
530     OH_Drawing_CanvasBind(cCanvas, cBitmap);
531     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
532 
533     EXPECT_EQ(OH_Drawing_TypographyGetHeight(typography) != 0.0, true);
534     EXPECT_EQ(OH_Drawing_TypographyGetLongestLine(typography) != 0.0, true);
535     EXPECT_EQ(OH_Drawing_TypographyGetMinIntrinsicWidth(typography) <=
536         OH_Drawing_TypographyGetMaxIntrinsicWidth(typography), true);
537     EXPECT_EQ(OH_Drawing_TypographyGetAlphabeticBaseline(typography) != 0.0, true);
538     EXPECT_EQ(OH_Drawing_TypographyGetIdeographicBaseline(typography) != 0.0, true);
539     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
540     OH_Drawing_DestroyTypography(typography);
541     OH_Drawing_DestroyTypographyHandler(handler);
542 }
543 
544 /*
545  * @tc.name: OH_Drawing_TypographyTest017
546  * @tc.desc: test for break strategy
547  * @tc.type: FUNC
548  */
549 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest017, TestSize.Level1)
550 {
551     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
552     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_GREEDY);
553 #ifndef USE_GRAPHIC_TEXT_GINE
554     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy_, BreakStrategy::BreakStrategyGreedy);
555 #else
556     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::GREEDY);
557 #endif
558     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_HIGH_QUALITY);
559 #ifndef USE_GRAPHIC_TEXT_GINE
560     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy_, BreakStrategy::BreakStrategyHighQuality);
561 #else
562     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::HIGH_QUALITY);
563 #endif
564     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_BALANCED);
565 #ifndef USE_GRAPHIC_TEXT_GINE
566     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy_, BreakStrategy::BreakStrategyBalanced);
567 #else
568     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::BALANCED);
569 #endif
570     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, -1);
571 #ifndef USE_GRAPHIC_TEXT_GINE
572     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy_, BreakStrategy::BreakStrategyGreedy);
573 #else
574     EXPECT_EQ(ConvertToOriginalText(typoStyle)->breakStrategy, BreakStrategy::GREEDY);
575 #endif
576 }
577 
578 /*
579  * @tc.name: OH_Drawing_TypographyTest018
580  * @tc.desc: test for word break type
581  * @tc.type: FUNC
582  */
583 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest018, TestSize.Level1)
584 {
585     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
586     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, WORD_BREAK_TYPE_NORMAL);
587 #ifndef USE_GRAPHIC_TEXT_GINE
588     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType_, WordBreakType::WordBreakTypeNormal);
589 #else
590     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::NORMAL);
591 #endif
592     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, WORD_BREAK_TYPE_BREAK_ALL);
593 #ifndef USE_GRAPHIC_TEXT_GINE
594     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType_, WordBreakType::WordBreakTypeBreakAll);
595 #else
596     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::BREAK_ALL);
597 #endif
598     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, WORD_BREAK_TYPE_BREAK_WORD);
599 #ifndef USE_GRAPHIC_TEXT_GINE
600     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType_, WordBreakType::WordBreakTypeBreakWord);
601 #else
602     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::BREAK_WORD);
603 #endif
604     OH_Drawing_SetTypographyTextWordBreakType(typoStyle, -1);
605 #ifndef USE_GRAPHIC_TEXT_GINE
606     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType_, WordBreakType::WordBreakTypeBreakWord);
607 #else
608     EXPECT_EQ(ConvertToOriginalText(typoStyle)->wordBreakType, WordBreakType::BREAK_WORD);
609 #endif
610 }
611 
612 /*
613  * @tc.name: OH_Drawing_TypographyTest019
614  * @tc.desc: test for ellipsis modal
615  * @tc.type: FUNC
616  */
617 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest019, TestSize.Level1)
618 {
619     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
620     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, ELLIPSIS_MODAL_HEAD);
621 #ifndef USE_GRAPHIC_TEXT_GINE
622     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal_, EllipsisModal::HEAD);
623 #else
624     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::HEAD);
625 #endif
626     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, ELLIPSIS_MODAL_MIDDLE);
627 #ifndef USE_GRAPHIC_TEXT_GINE
628     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal_, EllipsisModal::MIDDLE);
629 #else
630     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::MIDDLE);
631 #endif
632     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, ELLIPSIS_MODAL_TAIL);
633 #ifndef USE_GRAPHIC_TEXT_GINE
634     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal_, EllipsisModal::TAIL);
635 #else
636     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::TAIL);
637 #endif
638     OH_Drawing_SetTypographyTextEllipsisModal(typoStyle, -1);
639 #ifndef USE_GRAPHIC_TEXT_GINE
640     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal_, EllipsisModal::TAIL);
641 #else
642     EXPECT_EQ(ConvertToOriginalText(typoStyle)->ellipsisModal, EllipsisModal::TAIL);
643 #endif
644 }
645 
646 /*
647  * @tc.name: OH_Drawing_TypographyTest020
648  * @tc.desc: test for decoration style
649  * @tc.type: FUNC
650  */
651 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest020, TestSize.Level1)
652 {
653     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
654     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_SOLID);
655 #ifndef USE_GRAPHIC_TEXT_GINE
656     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle_, TextDecorationStyle::SOLID);
657 #else
658     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::SOLID);
659 #endif
660     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_DOUBLE);
661 #ifndef USE_GRAPHIC_TEXT_GINE
662     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle_, TextDecorationStyle::DOUBLE);
663 #else
664     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::DOUBLE);
665 #endif
666     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_DOTTED);
667 #ifndef USE_GRAPHIC_TEXT_GINE
668     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle_, TextDecorationStyle::DOTTED);
669 #else
670     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::DOTTED);
671 #endif
672     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_DASHED);
673 #ifndef USE_GRAPHIC_TEXT_GINE
674     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle_, TextDecorationStyle::DASHED);
675 #else
676     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::DASHED);
677 #endif
678     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_WAVY);
679 #ifndef USE_GRAPHIC_TEXT_GINE
680     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle_, TextDecorationStyle::WAVY);
681 #else
682     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::WAVY);
683 #endif
684     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, -1);
685 #ifndef USE_GRAPHIC_TEXT_GINE
686     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle_, TextDecorationStyle::SOLID);
687 #else
688     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationStyle, TextDecorationStyle::SOLID);
689 #endif
690 }
691 
692 /*
693  * @tc.name: OH_Drawing_TypographyTest021
694  * @tc.desc: test for decoration thickness scale
695  * @tc.type: FUNC
696  */
697 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest021, TestSize.Level1)
698 {
699     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
700     OH_Drawing_SetTextStyleDecorationThicknessScale(txtStyle, 10);
701 #ifndef USE_GRAPHIC_TEXT_GINE
702     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationThicknessMultiplier_, 10);
703 #else
704     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationThicknessScale, 10);
705 #endif
706     OH_Drawing_SetTextStyleDecorationThicknessScale(txtStyle, 20);
707 #ifndef USE_GRAPHIC_TEXT_GINE
708     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationThicknessMultiplier_, 20);
709 #else
710     EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationThicknessScale, 20);
711 #endif
712 }
713 
714 /*
715  * @tc.name: OH_Drawing_TypographyTest022
716  * @tc.desc: test for letter spacing
717  * @tc.type: FUNC
718  */
719 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest022, TestSize.Level1)
720 {
721     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
722     OH_Drawing_SetTextStyleLetterSpacing(txtStyle, 10);
723 #ifndef USE_GRAPHIC_TEXT_GINE
724     EXPECT_EQ(ConvertToOriginalText(txtStyle)->letterSpacing_, 10);
725 #else
726     EXPECT_EQ(ConvertToOriginalText(txtStyle)->letterSpacing, 10);
727 #endif
728     OH_Drawing_SetTextStyleLetterSpacing(txtStyle, 20);
729 #ifndef USE_GRAPHIC_TEXT_GINE
730     EXPECT_EQ(ConvertToOriginalText(txtStyle)->letterSpacing_, 20);
731 #else
732     EXPECT_EQ(ConvertToOriginalText(txtStyle)->letterSpacing, 20);
733 #endif
734 }
735 
736 /*
737  * @tc.name: OH_Drawing_TypographyTest023
738  * @tc.desc: test for word spacing
739  * @tc.type: FUNC
740  */
741 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest023, TestSize.Level1)
742 {
743     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
744     OH_Drawing_SetTextStyleWordSpacing(txtStyle, 10);
745 #ifndef USE_GRAPHIC_TEXT_GINE
746     EXPECT_EQ(ConvertToOriginalText(txtStyle)->wordSpacing_, 10);
747 #else
748     EXPECT_EQ(ConvertToOriginalText(txtStyle)->wordSpacing, 10);
749 #endif
750     OH_Drawing_SetTextStyleWordSpacing(txtStyle, 20);
751 #ifndef USE_GRAPHIC_TEXT_GINE
752     EXPECT_EQ(ConvertToOriginalText(txtStyle)->wordSpacing_, 20);
753 #else
754     EXPECT_EQ(ConvertToOriginalText(txtStyle)->wordSpacing, 20);
755 #endif
756 }
757 
758 /*
759  * @tc.name: OH_Drawing_TypographyTest024
760  * @tc.desc: test for ellipsis modal
761  * @tc.type: FUNC
762  */
763 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest024, TestSize.Level1)
764 {
765     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
766     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, ELLIPSIS_MODAL_HEAD);
767 #ifndef USE_GRAPHIC_TEXT_GINE
768     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal_, EllipsisModal::HEAD);
769 #else
770     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::HEAD);
771 #endif
772     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, ELLIPSIS_MODAL_MIDDLE);
773 #ifndef USE_GRAPHIC_TEXT_GINE
774     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal_, EllipsisModal::MIDDLE);
775 #else
776     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::MIDDLE);
777 #endif
778     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, ELLIPSIS_MODAL_TAIL);
779 #ifndef USE_GRAPHIC_TEXT_GINE
780     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal_, EllipsisModal::TAIL);
781 #else
782     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::TAIL);
783 #endif
784     OH_Drawing_SetTextStyleEllipsisModal(txtStyle, -1);
785 #ifndef USE_GRAPHIC_TEXT_GINE
786     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal_, EllipsisModal::TAIL);
787 #else
788     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsisModal, EllipsisModal::TAIL);
789 #endif
790 }
791 
792 /*
793  * @tc.name: OH_Drawing_TypographyTest025
794  * @tc.desc: test for set ellipsis
795  * @tc.type: FUNC
796  */
797 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest025, TestSize.Level1)
798 {
799     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
800     OH_Drawing_SetTextStyleEllipsis(txtStyle, "...");
801 #ifndef USE_GRAPHIC_TEXT_GINE
802     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsis_, u"...");
803 #else
804     EXPECT_EQ(ConvertToOriginalText(txtStyle)->ellipsis, u"...");
805 #endif
806 }
807 
808 /*
809  * @tc.name: OH_Drawing_TypographyTest026
810  * @tc.desc: test for typography and txtStyle
811  * @tc.type: FUNC
812  */
813 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest026, TestSize.Level1)
814 {
815     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
816     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
817     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
818         OH_Drawing_CreateFontCollection());
819     EXPECT_TRUE(handler != nullptr);
820     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
821     double fontSize = 30;
822     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
823     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
824     bool halfLeading = true;
825     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
826     const char* fontFamilies[] = {"Roboto"};
827     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
828     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
829     const char* text = "OpenHarmony\n";
830     OH_Drawing_TypographyHandlerAddText(handler, text);
831     OH_Drawing_PlaceholderSpan placeholderSpan = {20, 40,
832         ALIGNMENT_OFFSET_AT_BASELINE, TEXT_BASELINE_ALPHABETIC, 10};
833     OH_Drawing_TypographyHandlerAddPlaceholder(handler, &placeholderSpan);
834     OH_Drawing_TypographyHandlerPopTextStyle(handler);
835     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
836     double maxWidth = 800.0;
837     OH_Drawing_TypographyLayout(typography, maxWidth);
838     double position[2] = {10.0, 15.0};
839     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
840     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
841     uint32_t width = 20;
842     uint32_t height = 40;
843     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
844     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
845     OH_Drawing_CanvasBind(cCanvas, cBitmap);
846     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
847     EXPECT_EQ(OH_Drawing_TypographyDidExceedMaxLines(typography) != true, true);
848     OH_Drawing_RectHeightStyle heightStyle = RECT_HEIGHT_STYLE_TIGHT;
849     OH_Drawing_RectWidthStyle widthStyle = RECT_WIDTH_STYLE_TIGHT;
850     EXPECT_EQ(OH_Drawing_TypographyGetRectsForRange(typography, 1, 2, heightStyle, widthStyle) != nullptr, true);
851     EXPECT_EQ(OH_Drawing_TypographyGetRectsForPlaceholders(typography) != nullptr, true);
852     EXPECT_EQ(OH_Drawing_TypographyGetGlyphPositionAtCoordinate(typography, 1, 0) != nullptr, true);
853     EXPECT_EQ(OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster(typography, 1, 0) != nullptr, true);
854     EXPECT_EQ(OH_Drawing_TypographyGetWordBoundary(typography, 1) != nullptr, true);
855     EXPECT_EQ(OH_Drawing_TypographyGetLineTextRange(typography, 1, true) != nullptr, true);
856     EXPECT_EQ(OH_Drawing_TypographyGetLineCount(typography) != 0, true);
857     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
858     OH_Drawing_DestroyTypography(typography);
859     OH_Drawing_DestroyTypographyHandler(handler);
860 }
861 
862 /*
863  * @tc.name: OH_Drawing_TypographyTest027
864  * @tc.desc: test for getting line info for text typography
865  * @tc.type: FUNC
866  */
867 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest027, TestSize.Level1)
868 {
869     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
870     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
871     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
872         OH_Drawing_CreateFontCollection());
873     EXPECT_TRUE(handler != nullptr);
874     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
875     double fontSize = 30;
876     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
877     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
878     bool halfLeading = true;
879     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
880     const char* fontFamilies[] = {"Roboto"};
881     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
882     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
883     const char* text = "OpenHarmony\n";
884     OH_Drawing_TypographyHandlerAddText(handler, text);
885     OH_Drawing_TypographyHandlerPopTextStyle(handler);
886     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
887     double maxWidth = 800.0;
888     OH_Drawing_TypographyLayout(typography, maxWidth);
889     double position[2] = {10.0, 15.0};
890     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
891     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
892     uint32_t width = 20;
893     uint32_t height = 40;
894     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
895     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
896     OH_Drawing_CanvasBind(cCanvas, cBitmap);
897     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
898     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
899     int lineNum = 0;
900     bool oneLine = true;
901     bool includeWhitespace = true;
902     OH_Drawing_LineMetrics lineMetrics;
903     EXPECT_EQ(OH_Drawing_TypographyGetLineInfo(typography, lineNum, oneLine, includeWhitespace, nullptr), false);
904     EXPECT_EQ(OH_Drawing_TypographyGetLineInfo(typography, -1, oneLine, includeWhitespace, &lineMetrics), false);
905     EXPECT_EQ(OH_Drawing_TypographyGetLineInfo(typography, lineNum, oneLine, includeWhitespace, &lineMetrics), true);
906     OH_Drawing_DestroyTypography(typography);
907     OH_Drawing_DestroyTypographyHandler(handler);
908 }
909 
910 /*
911  * @tc.name: OH_Drawing_TypographyTest028
912  * @tc.desc: test for getting line info for text typography
913  * @tc.type: FUNC
914  */
915 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest028, TestSize.Level1)
916 {
917     OH_Drawing_TextShadow* textShadow = OH_Drawing_CreateTextShadow();
918     EXPECT_EQ(textShadow == nullptr, false);
919     OH_Drawing_DestroyTextShadow(textShadow);
920     OH_Drawing_DestroyTextShadow(nullptr);
921 }
922 
923 /*
924  * @tc.name: OH_Drawing_TypographyTest029
925  * @tc.desc: test for font weight of text typography
926  * @tc.type: FUNC
927  */
928 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest029, TestSize.Level1)
929 {
930     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
931     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_100);
932 #ifndef USE_GRAPHIC_TEXT_GINE
933     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W100);
934 #else
935     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W100);
936 #endif
937     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_200);
938 #ifndef USE_GRAPHIC_TEXT_GINE
939     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W200);
940 #else
941     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W200);
942 #endif
943     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_300);
944 #ifndef USE_GRAPHIC_TEXT_GINE
945     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W300);
946 #else
947     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W300);
948 #endif
949     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_400);
950 #ifndef USE_GRAPHIC_TEXT_GINE
951     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W400);
952 #else
953     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W400);
954 #endif
955 }
956 
957 /*
958  * @tc.name: OH_Drawing_TypographyTest030
959  * @tc.desc: test for font style of text typography
960  * @tc.type: FUNC
961  */
962 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest030, TestSize.Level1)
963 {
964     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
965     OH_Drawing_SetTypographyTextFontStyle(typoStyle, FONT_STYLE_NORMAL);
966 #ifndef USE_GRAPHIC_TEXT_GINE
967     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle_, FontStyle::NORMAL);
968 #else
969     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle, FontStyle::NORMAL);
970 #endif
971     OH_Drawing_SetTypographyTextFontStyle(typoStyle, FONT_STYLE_ITALIC);
972 #ifndef USE_GRAPHIC_TEXT_GINE
973     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle_, FontStyle::ITALIC);
974 #else
975     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle, FontStyle::ITALIC);
976 #endif
977     OH_Drawing_SetTypographyTextFontStyle(typoStyle, -1);
978 #ifndef USE_GRAPHIC_TEXT_GINE
979     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle_, FontStyle::NORMAL);
980 #else
981     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontStyle, FontStyle::NORMAL);
982 #endif
983 }
984 
985 /*
986  * @tc.name: OH_Drawing_TypographyTest031
987  * @tc.desc: test for font family of text typography
988  * @tc.type: FUNC
989  */
990 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest031, TestSize.Level1)
991 {
992     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
993     OH_Drawing_SetTypographyTextFontFamily(typoStyle, "monospace");
994 #ifndef USE_GRAPHIC_TEXT_GINE
995     EXPECT_EQ(ConvertToOriginalText(typoStyle)-> fontFamily_, "monospace");
996 #else
997     EXPECT_EQ(ConvertToOriginalText(typoStyle)-> fontFamily, "monospace");
998 #endif
999 }
1000 
1001 /*
1002  * @tc.name: OH_Drawing_TypographyTest032
1003  * @tc.desc: test for font size of text typography
1004  * @tc.type: FUNC
1005  */
1006 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest032, TestSize.Level1)
1007 {
1008     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1009     OH_Drawing_SetTypographyTextFontSize(typoStyle, 80);
1010 #ifndef USE_GRAPHIC_TEXT_GINE
1011     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontSize_, 80);
1012 #else
1013     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontSize, 80);
1014 #endif
1015     OH_Drawing_SetTypographyTextFontSize(typoStyle, 40);
1016 #ifndef USE_GRAPHIC_TEXT_GINE
1017     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontSize_, 40);
1018 #else
1019     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontSize, 40);
1020 #endif
1021 }
1022 
1023 /*
1024  * @tc.name: OH_Drawing_TypographyTest033
1025  * @tc.desc: test for font height of text typography
1026  * @tc.type: FUNC
1027  */
1028 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest033, TestSize.Level1)
1029 {
1030     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1031     OH_Drawing_SetTypographyTextFontHeight(typoStyle, 0.0);
1032 #ifndef USE_GRAPHIC_TEXT_GINE
1033     EXPECT_EQ(ConvertToOriginalText(typoStyle)->height_, 0.0);
1034 #else
1035     EXPECT_EQ(ConvertToOriginalText(typoStyle)->heightScale, 0.0);
1036 #endif
1037 }
1038 
1039 /*
1040  * @tc.name: OH_Drawing_TypographyTest034
1041  * @tc.desc: test for font style of line style for text typography
1042  * @tc.type: FUNC
1043  */
1044 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest034, TestSize.Level1)
1045 {
1046     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1047     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, FONT_STYLE_NORMAL);
1048 #ifndef USE_GRAPHIC_TEXT_GINE
1049     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle_, FontStyle::NORMAL);
1050 #else
1051     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle, FontStyle::NORMAL);
1052 #endif
1053     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, FONT_STYLE_ITALIC);
1054 #ifndef USE_GRAPHIC_TEXT_GINE
1055     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle_, FontStyle::ITALIC);
1056 #else
1057     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle, FontStyle::ITALIC);
1058 #endif
1059     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, -1);
1060 #ifndef USE_GRAPHIC_TEXT_GINE
1061     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle_, FontStyle::NORMAL);
1062 #else
1063     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontStyle, FontStyle::NORMAL);
1064 #endif
1065 }
1066 
1067 
1068 /*
1069  * @tc.name: OH_Drawing_TypographyTest035
1070  * @tc.desc: test for font weight of line style for text typography
1071  * @tc.type: FUNC
1072  */
1073 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest035, TestSize.Level1)
1074 {
1075     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1076     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_100);
1077 #ifndef USE_GRAPHIC_TEXT_GINE
1078     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W100);
1079 #else
1080     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W100);
1081 #endif
1082     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_200);
1083 #ifndef USE_GRAPHIC_TEXT_GINE
1084     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W200);
1085 #else
1086     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W200);
1087 #endif
1088     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_300);
1089 #ifndef USE_GRAPHIC_TEXT_GINE
1090     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W300);
1091 #else
1092     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W300);
1093 #endif
1094     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_400);
1095 #ifndef USE_GRAPHIC_TEXT_GINE
1096     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W400);
1097 #else
1098     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W400);
1099 #endif
1100     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_500);
1101 #ifndef USE_GRAPHIC_TEXT_GINE
1102     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W500);
1103 #else
1104     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W500);
1105 #endif
1106 }
1107 
1108 /*
1109  * @tc.name: OH_Drawing_TypographyTest036
1110  * @tc.desc: test for font size of line style for text typography
1111  * @tc.type: FUNC
1112  */
1113 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest036, TestSize.Level1)
1114 {
1115     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1116     OH_Drawing_SetTypographyTextLineStyleFontSize(typoStyle, 80);
1117 #ifndef USE_GRAPHIC_TEXT_GINE
1118     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontSize_, 80);
1119 #else
1120     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontSize, 80);
1121 #endif
1122     OH_Drawing_SetTypographyTextLineStyleFontSize(typoStyle, 40);
1123 #ifndef USE_GRAPHIC_TEXT_GINE
1124     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontSize_, 40);
1125 #else
1126     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontSize, 40);
1127 #endif
1128 }
1129 
1130 
1131 /*
1132  * @tc.name: OH_Drawing_TypographyTest037
1133  * @tc.desc: test for font families of line style for text typography
1134  * @tc.type: FUNC
1135  */
1136 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest037, TestSize.Level1)
1137 {
1138     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1139     const char* fontFamilies[] = {"Roboto"};
1140     OH_Drawing_SetTypographyTextLineStyleFontFamilies(typoStyle, 1, fontFamilies);
1141     std::vector<std::string> fontFamiliesResult = {"Roboto"};
1142 #ifndef USE_GRAPHIC_TEXT_GINE
1143     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontFamilies_, fontFamiliesResult);
1144 #else
1145     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontFamilies, fontFamiliesResult);
1146 #endif
1147 }
1148 
1149 /*
1150  * @tc.name: OH_Drawing_TypographyTest038
1151  * @tc.desc: test for spacing scale of line style for text typography
1152  * @tc.type: FUNC
1153  */
1154 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest038, TestSize.Level1)
1155 {
1156     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1157     OH_Drawing_SetTypographyTextLineStyleSpacingScale(typoStyle, 1.0);
1158 #ifndef USE_GRAPHIC_TEXT_GINE
1159     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleSpacingScale_, 1.0);
1160 #else
1161     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleSpacingScale, 1.0);
1162 #endif
1163     OH_Drawing_SetTypographyTextLineStyleSpacingScale(typoStyle, 2.0);
1164 #ifndef USE_GRAPHIC_TEXT_GINE
1165     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleSpacingScale_, 2.0);
1166 #else
1167     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleSpacingScale, 2.0);
1168 #endif
1169 }
1170 
1171 
1172 /*
1173  * @tc.name: OH_Drawing_TypographyTest039
1174  * @tc.desc: test for font height of line style for text typography
1175  * @tc.type: FUNC
1176  */
1177 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest039, TestSize.Level1)
1178 {
1179     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1180     OH_Drawing_SetTypographyTextLineStyleFontHeight(typoStyle, 0.0);
1181 #ifndef USE_GRAPHIC_TEXT_GINE
1182     EXPECT_EQ(ConvertToOriginalText(typoStyle)->linestyleHeight_, 0.0);
1183 #else
1184     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleHeightScale, 0.0);
1185 #endif
1186 }
1187 
1188 /*
1189  * @tc.name: OH_Drawing_TypographyTest040
1190  * @tc.desc: test for line metrics for text typography
1191  * @tc.type: FUNC
1192  */
1193 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest040, TestSize.Level1)
1194 {
1195     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1196     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1197     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1198         OH_Drawing_CreateFontCollection());
1199     EXPECT_TRUE(handler != nullptr);
1200     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1201     double fontSize = 30;
1202     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1203     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1204     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
1205     const char* fontFamilies[] = {"Roboto"};
1206     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1207     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1208     const char* text = "OpenHarmony\n";
1209     OH_Drawing_TypographyHandlerAddText(handler, text);
1210     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1211     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1212     double maxWidth = 800.0;
1213     OH_Drawing_TypographyLayout(typography, maxWidth);
1214     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
1215     double position[2] = {10.0, 15.0};
1216     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1217     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1218     uint32_t width = 20;
1219     uint32_t height = 40;
1220     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1221     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1222     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1223     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1224     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1225     OH_Drawing_FontDescriptor *descriptor = OH_Drawing_CreateFontDescriptor();
1226     OH_Drawing_FontParser* parser = OH_Drawing_CreateFontParser();
1227 
1228     static const std::string FILE_NAME = "/system/fonts/visibility_list.json";
1229     std::ifstream fileStream(FILE_NAME.c_str());
1230     if (fileStream.is_open()) {
1231         size_t fontNum;
1232         char** list = OH_Drawing_FontParserGetSystemFontList(parser, &fontNum);
1233         EXPECT_EQ(list != nullptr, true);
1234         const char *name = "OS Sans Digit";
1235         EXPECT_EQ(OH_Drawing_FontParserGetFontByName(parser, name) != nullptr, true);
1236         OH_Drawing_DestroySystemFontList(list, fontNum);
1237     }
1238     OH_Drawing_DestroyFontParser(parser);
1239     OH_Drawing_DestroyFontDescriptor(descriptor);
1240     OH_Drawing_LineMetrics* vectorMetrics = OH_Drawing_TypographyGetLineMetrics(typography);
1241     EXPECT_EQ(vectorMetrics != nullptr, true);
1242     EXPECT_EQ(OH_Drawing_LineMetricsGetSize(vectorMetrics) != 0, true);
1243     OH_Drawing_DestroyLineMetrics(vectorMetrics);
1244     OH_Drawing_LineMetrics* metrics = new OH_Drawing_LineMetrics();
1245     EXPECT_EQ(OH_Drawing_TypographyGetLineMetricsAt(typography, 0, metrics), true);
1246     OH_Drawing_DestroyTypography(typography);
1247     OH_Drawing_DestroyTypographyHandler(handler);
1248 }
1249 
1250 /*
1251  * @tc.name: OH_Drawing_TypographyTest041
1252  * @tc.desc: test for font weight of line style for text typography
1253  * @tc.type: FUNC
1254  */
1255 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest041, TestSize.Level1)
1256 {
1257     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1258     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_600);
1259 #ifndef USE_GRAPHIC_TEXT_GINE
1260     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W600);
1261 #else
1262     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W600);
1263 #endif
1264     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_700);
1265 #ifndef USE_GRAPHIC_TEXT_GINE
1266     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W700);
1267 #else
1268     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W700);
1269 #endif
1270     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_800);
1271 #ifndef USE_GRAPHIC_TEXT_GINE
1272     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W800);
1273 #else
1274     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W800);
1275 #endif
1276     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, FONT_WEIGHT_900);
1277 #ifndef USE_GRAPHIC_TEXT_GINE
1278     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight_, FontWeight::W900);
1279 #else
1280     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W900);
1281 #endif
1282 }
1283 
1284 /*
1285  * @tc.name: OH_Drawing_TypographyTest042
1286  * @tc.desc: test for text shadow for textstyle
1287  * @tc.type: FUNC
1288  */
1289 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest042, TestSize.Level1)
1290 {
1291     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1292     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1293     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1294         OH_Drawing_CreateFontCollection());
1295     EXPECT_TRUE(handler != nullptr);
1296     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1297     double fontSize = 30;
1298     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1299     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1300     bool halfLeading = true;
1301     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1302     const char* fontFamilies[] = {"Roboto"};
1303     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1304     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1305     const char* text = "OpenHarmony\n";
1306     OH_Drawing_TypographyHandlerAddText(handler, text);
1307     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1308     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1309     double maxWidth = 800.0;
1310     OH_Drawing_TypographyLayout(typography, maxWidth);
1311     double position[2] = {10.0, 15.0};
1312     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1313     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1314     uint32_t width = 20;
1315     uint32_t height = 40;
1316     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1317     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1318     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1319     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1320     EXPECT_EQ(OH_Drawing_TextStyleGetShadows(txtStyle) != nullptr, true);
1321     OH_Drawing_TextStyleClearShadows(txtStyle);
1322     OH_Drawing_TextShadow* textshadows = OH_Drawing_TextStyleGetShadows(txtStyle);
1323     OH_Drawing_DestroyTextShadows(textshadows);
1324     OH_Drawing_DestroyTextShadows(nullptr);
1325     OH_Drawing_TextStyleAddShadow(txtStyle, nullptr);
1326     OH_Drawing_TextStyleAddShadow(txtStyle, OH_Drawing_CreateTextShadow());
1327     EXPECT_EQ(OH_Drawing_TextStyleGetShadowWithIndex(txtStyle, 0) != nullptr, true);
1328     EXPECT_EQ(OH_Drawing_TextStyleGetShadowWithIndex(txtStyle, 10000000) == nullptr, true);
1329     EXPECT_EQ(OH_Drawing_TextStyleGetShadowWithIndex(nullptr, 0) == nullptr, true);
1330     EXPECT_EQ(OH_Drawing_TextStyleGetShadowCount(txtStyle), 1);
1331     EXPECT_EQ(OH_Drawing_TextStyleGetShadowCount(nullptr), 0);
1332     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1333     OH_Drawing_DestroyTypography(typography);
1334     OH_Drawing_DestroyTypographyHandler(handler);
1335 }
1336 
1337 /*
1338  * @tc.name: OH_Drawing_TypographyTest043
1339  * @tc.desc: test for foreground brush for textstyle
1340  * @tc.type: FUNC
1341  */
1342 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest043, TestSize.Level1)
1343 {
1344     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1345     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1346     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1347         OH_Drawing_CreateFontCollection());
1348     EXPECT_TRUE(handler != nullptr);
1349     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1350     double fontSize = 30;
1351     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1352     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1353     bool halfLeading = true;
1354     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1355     const char* fontFamilies[] = {"Roboto"};
1356     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1357     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1358     const char* text = "OpenHarmony\n";
1359     OH_Drawing_TypographyHandlerAddText(handler, text);
1360     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1361     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1362     double maxWidth = 800.0;
1363     OH_Drawing_TypographyLayout(typography, maxWidth);
1364     double position[2] = {10.0, 15.0};
1365     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1366     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1367     uint32_t width = 20;
1368     uint32_t height = 40;
1369     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1370     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1371     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1372     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1373     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1374     OH_Drawing_Brush *foregroundBrush = OH_Drawing_BrushCreate();
1375     uint8_t alpha = 128;
1376     OH_Drawing_BrushSetAlpha(foregroundBrush, alpha);
1377     OH_Drawing_SetTextStyleForegroundBrush(txtStyle, nullptr);
1378     OH_Drawing_SetTextStyleForegroundBrush(txtStyle, foregroundBrush);
1379     OH_Drawing_Brush *resForegroundBrush = OH_Drawing_BrushCreate();
1380     OH_Drawing_TextStyleGetForegroundBrush(txtStyle, nullptr);
1381     OH_Drawing_TextStyleGetForegroundBrush(txtStyle, resForegroundBrush);
1382     EXPECT_EQ(OH_Drawing_BrushGetAlpha(resForegroundBrush), alpha);
1383     OH_Drawing_BrushDestroy(resForegroundBrush);
1384     OH_Drawing_BrushDestroy(foregroundBrush);
1385     OH_Drawing_DestroyTypography(typography);
1386     OH_Drawing_DestroyTypographyHandler(handler);
1387 }
1388 
1389 /*
1390  * @tc.name: OH_Drawing_TypographyTest044
1391  * @tc.desc: test for effectiveAlignment, isLineUnlimited, isEllipsized for text typography
1392  * @tc.type: FUNC
1393  */
1394 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest044, TestSize.Level1)
1395 {
1396     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1397     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1398     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1399         OH_Drawing_CreateFontCollection());
1400     EXPECT_TRUE(handler != nullptr);
1401 
1402     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1403     double fontSize = 30;
1404     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1405     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1406     bool halfLeading = true;
1407     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1408     const char* fontFamilies[] = {"Roboto"};
1409     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1410     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1411     const char* text = "OpenHarmony\n";
1412     OH_Drawing_TypographyHandlerAddText(handler, text);
1413     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1414     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1415     double maxWidth = 800.0;
1416     OH_Drawing_TypographyLayout(typography, maxWidth);
1417     double position[2] = {10.0, 15.0};
1418     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1419     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1420     uint32_t width = 20;
1421     uint32_t height = 40;
1422     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1423     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1424     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1425     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1426     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1427     OH_Drawing_Font_Metrics fontmetrics;
1428     EXPECT_EQ(OH_Drawing_TextStyleGetFontMetrics(typography, txtStyle, &fontmetrics), true);
1429     EXPECT_EQ(OH_Drawing_TextStyleGetFontMetrics(nullptr, txtStyle, &fontmetrics), false);
1430     OH_Drawing_DisableFontCollectionFallback(OH_Drawing_CreateFontCollection());
1431     OH_Drawing_DisableFontCollectionFallback(nullptr);
1432     OH_Drawing_DisableFontCollectionSystemFont(OH_Drawing_CreateFontCollection());
1433     OH_Drawing_SetTypographyTextEllipsis(typoStyle, text);
1434     OH_Drawing_SetTypographyTextLocale(typoStyle, text);
1435     OH_Drawing_SetTypographyTextSplitRatio(typoStyle, fontSize);
1436     OH_Drawing_TypographyGetTextStyle(typoStyle);
1437     EXPECT_EQ(OH_Drawing_TypographyGetEffectiveAlignment(typoStyle) >= 0, true);
1438     EXPECT_EQ(OH_Drawing_TypographyIsLineUnlimited(typoStyle) != 0, true);
1439     EXPECT_EQ(OH_Drawing_TypographyIsEllipsized(typoStyle) != 0, true);
1440     OH_Drawing_SetTypographyTextStyle(typoStyle, txtStyle);
1441     OH_Drawing_DestroyTypography(typography);
1442     OH_Drawing_DestroyTypographyHandler(handler);
1443 }
1444 
1445 /*
1446  * @tc.name: OH_Drawing_TypographyTest045
1447  * @tc.desc: test for background brush for textstyle
1448  * @tc.type: FUNC
1449  */
1450 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest045, TestSize.Level1)
1451 {
1452     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1453     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1454     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1455         OH_Drawing_CreateFontCollection());
1456     EXPECT_TRUE(handler != nullptr);
1457 
1458     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1459     double fontSize = 30;
1460     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1461     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1462     bool halfLeading = true;
1463     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1464     const char* fontFamilies[] = {"Roboto"};
1465     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1466     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1467     const char* text = "OpenHarmony\n";
1468     OH_Drawing_TypographyHandlerAddText(handler, text);
1469     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1470     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1471     double maxWidth = 800.0;
1472     OH_Drawing_TypographyLayout(typography, maxWidth);
1473     double position[2] = {10.0, 15.0};
1474     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1475     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1476     uint32_t width = 20;
1477     uint32_t height = 40;
1478     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1479     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1480     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1481     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1482     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1483     OH_Drawing_Brush *backgroundBrush = OH_Drawing_BrushCreate();
1484     uint8_t backgroundAlpha = 64;
1485     OH_Drawing_BrushSetAlpha(backgroundBrush, backgroundAlpha);
1486     OH_Drawing_SetTextStyleBackgroundBrush(txtStyle, nullptr);
1487     OH_Drawing_SetTextStyleBackgroundBrush(txtStyle, backgroundBrush);
1488     OH_Drawing_Brush *resBackgroundBrush = OH_Drawing_BrushCreate();
1489     OH_Drawing_TextStyleGetBackgroundBrush(txtStyle, nullptr);
1490     OH_Drawing_TextStyleGetBackgroundBrush(txtStyle, resBackgroundBrush);
1491     EXPECT_EQ(OH_Drawing_BrushGetAlpha(resBackgroundBrush), backgroundAlpha);
1492     OH_Drawing_BrushDestroy(resBackgroundBrush);
1493     OH_Drawing_BrushDestroy(backgroundBrush);
1494     OH_Drawing_DestroyTypography(typography);
1495     OH_Drawing_DestroyTypographyHandler(handler);
1496 }
1497 
1498 /*
1499  * @tc.name: OH_Drawing_TypographyTest046
1500  * @tc.desc: test for background pen for textstyle
1501  * @tc.type: FUNC
1502  */
1503 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest046, TestSize.Level1)
1504 {
1505     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1506     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1507     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1508         OH_Drawing_CreateFontCollection());
1509     EXPECT_TRUE(handler != nullptr);
1510 
1511     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1512     double fontSize = 30;
1513     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1514     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1515     bool halfLeading = true;
1516     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1517     const char* fontFamilies[] = {"Roboto"};
1518     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1519     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1520     const char* text = "OpenHarmony\n";
1521     OH_Drawing_TypographyHandlerAddText(handler, text);
1522     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1523     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1524     double maxWidth = 800.0;
1525     OH_Drawing_TypographyLayout(typography, maxWidth);
1526     double position[2] = {10.0, 15.0};
1527     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1528     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1529     uint32_t width = 20;
1530     uint32_t height = 40;
1531     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1532     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1533     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1534     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1535     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1536     OH_Drawing_Pen *backgroundPen = OH_Drawing_PenCreate();
1537     float backgroundPenWidth = 10;
1538     OH_Drawing_PenSetWidth(backgroundPen, backgroundPenWidth);
1539     OH_Drawing_SetTextStyleBackgroundPen(txtStyle, nullptr);
1540     OH_Drawing_SetTextStyleBackgroundPen(txtStyle, backgroundPen);
1541     OH_Drawing_Pen *resBackgroundPen = OH_Drawing_PenCreate();
1542     OH_Drawing_TextStyleGetBackgroundPen(txtStyle, nullptr);
1543     OH_Drawing_TextStyleGetBackgroundPen(txtStyle, resBackgroundPen);
1544     EXPECT_EQ(OH_Drawing_PenGetWidth(resBackgroundPen), backgroundPenWidth);
1545     OH_Drawing_PenDestroy(resBackgroundPen);
1546     OH_Drawing_PenDestroy(backgroundPen);
1547     OH_Drawing_DestroyTypography(typography);
1548     OH_Drawing_DestroyTypographyHandler(handler);
1549 }
1550 
1551 /*
1552  * @tc.name: OH_Drawing_TypographyTest047
1553  * @tc.desc: test for foreground pen for textstyle
1554  * @tc.type: FUNC
1555  */
1556 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest047, TestSize.Level1)
1557 {
1558     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1559     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1560     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1561         OH_Drawing_CreateFontCollection());
1562     EXPECT_TRUE(handler != nullptr);
1563     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
1564     double fontSize = 30;
1565     OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
1566     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
1567     bool halfLeading = true;
1568     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1569     const char* fontFamilies[] = {"Roboto"};
1570     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1571     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
1572     const char* text = "OpenHarmony\n";
1573     OH_Drawing_TypographyHandlerAddText(handler, text);
1574     OH_Drawing_TypographyHandlerPopTextStyle(handler);
1575     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1576     double maxWidth = 800.0;
1577     OH_Drawing_TypographyLayout(typography, maxWidth);
1578     double position[2] = {10.0, 15.0};
1579     OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
1580     OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
1581     uint32_t width = 20;
1582     uint32_t height = 40;
1583     OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
1584     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
1585     OH_Drawing_CanvasBind(cCanvas, cBitmap);
1586     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
1587     OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
1588     OH_Drawing_Pen *foregroundPen = OH_Drawing_PenCreate();
1589     float foregroundPenWidth = 20;
1590     OH_Drawing_PenSetWidth(foregroundPen, foregroundPenWidth);
1591     OH_Drawing_SetTextStyleForegroundPen(txtStyle, nullptr);
1592     OH_Drawing_SetTextStyleForegroundPen(txtStyle, foregroundPen);
1593     OH_Drawing_Pen *resForegroundPen = OH_Drawing_PenCreate();
1594     OH_Drawing_TextStyleGetForegroundPen(txtStyle, nullptr);
1595     OH_Drawing_TextStyleGetForegroundPen(txtStyle, resForegroundPen);
1596     EXPECT_EQ(OH_Drawing_PenGetWidth(resForegroundPen), foregroundPenWidth);
1597     OH_Drawing_PenDestroy(resForegroundPen);
1598     OH_Drawing_PenDestroy(foregroundPen);
1599     OH_Drawing_DestroyTypography(typography);
1600     OH_Drawing_DestroyTypographyHandler(handler);
1601 }
1602 
1603 /*
1604  * @tc.name: OH_Drawing_TypographyTest048
1605  * @tc.desc: test for font weight for text typography
1606  * @tc.type: FUNC
1607  */
1608 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest048, TestSize.Level1)
1609 {
1610     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1611     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_500);
1612 #ifndef USE_GRAPHIC_TEXT_GINE
1613     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W500);
1614 #else
1615     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W500);
1616 #endif
1617     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_600);
1618 #ifndef USE_GRAPHIC_TEXT_GINE
1619     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W600);
1620 #else
1621     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W600);
1622 #endif
1623     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_700);
1624 #ifndef USE_GRAPHIC_TEXT_GINE
1625     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W700);
1626 #else
1627     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W700);
1628 #endif
1629     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_800);
1630 #ifndef USE_GRAPHIC_TEXT_GINE
1631     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W800);
1632 #else
1633     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W800);
1634 #endif
1635     OH_Drawing_SetTypographyTextFontWeight(typoStyle, FONT_WEIGHT_900);
1636 #ifndef USE_GRAPHIC_TEXT_GINE
1637     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight_, FontWeight::W900);
1638 #else
1639     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W900);
1640 #endif
1641 }
1642 
1643 /*
1644  * @tc.name: OH_Drawing_TypographyTest049
1645  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1646  * @tc.type: FUNC
1647  */
1648 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest049, TestSize.Level1)
1649 {
1650     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1651     bool halfLeading = true;
1652     OH_Drawing_SetTypographyTextHalfLeading(typoStyle, halfLeading);
1653     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->halfLeading);
1654     OH_Drawing_SetTypographyTextLineStyleHalfLeading(typoStyle, halfLeading);
1655     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->lineStyleHalfLeading);
1656     bool uselineStyle = true;
1657     OH_Drawing_SetTypographyTextUseLineStyle(typoStyle, uselineStyle);
1658     EXPECT_TRUE(ConvertToOriginalText(typoStyle)->useLineStyle);
1659     bool linestyleOnly = false;
1660     OH_Drawing_SetTypographyTextLineStyleOnly(typoStyle, linestyleOnly);
1661     EXPECT_FALSE(ConvertToOriginalText(typoStyle)->lineStyleOnly);
1662     OH_Drawing_SetTypographyTextLineStyleOnly(nullptr, 0);
1663     OH_Drawing_DestroyTypographyStyle(typoStyle);
1664 }
1665 
1666 
1667 /*
1668  * @tc.name: OH_Drawing_TypographyTest050
1669  * @tc.desc: test for getting numbers for textstyle
1670  * @tc.type: FUNC
1671  */
1672 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest050, TestSize.Level1)
1673 {
1674     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1675     OH_Drawing_SetTextStyleColor(txtStyle, 1);
1676     EXPECT_EQ(OH_Drawing_TextStyleGetColor(txtStyle), 1);
1677     EXPECT_EQ(OH_Drawing_TextStyleGetColor(nullptr), 0xFFFFFFFF);
1678     OH_Drawing_SetTextStyleDecorationStyle(txtStyle, TEXT_DECORATION_STYLE_SOLID);
1679     EXPECT_EQ(OH_Drawing_TextStyleGetDecorationStyle(txtStyle), 0);
1680     EXPECT_EQ(OH_Drawing_TextStyleGetDecorationStyle(nullptr), TEXT_DECORATION_STYLE_SOLID);
1681     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_100);
1682     EXPECT_EQ(OH_Drawing_TextStyleGetFontWeight(txtStyle), 0);
1683     EXPECT_EQ(OH_Drawing_TextStyleGetFontWeight(nullptr), FONT_WEIGHT_400);
1684     OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_NORMAL);
1685     EXPECT_EQ(OH_Drawing_TextStyleGetFontStyle(txtStyle), 0);
1686     EXPECT_EQ(OH_Drawing_TextStyleGetFontStyle(nullptr), FONT_STYLE_NORMAL);
1687     OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
1688     EXPECT_EQ(OH_Drawing_TextStyleGetBaseline(txtStyle), 0);
1689     EXPECT_EQ(OH_Drawing_TextStyleGetBaseline(nullptr), TEXT_BASELINE_ALPHABETIC);
1690     const char* fontFamilies[] = {"Roboto"};
1691     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
1692     size_t fontFamiliesNumber;
1693     char** fontFamiliesList = OH_Drawing_TextStyleGetFontFamilies(txtStyle, &fontFamiliesNumber);
1694     EXPECT_EQ(fontFamiliesList != nullptr, true);
1695     EXPECT_EQ(OH_Drawing_TextStyleGetFontFamilies(nullptr, &fontFamiliesNumber) == nullptr, true);
1696     OH_Drawing_TextStyleDestroyFontFamilies(fontFamiliesList, fontFamiliesNumber);
1697     OH_Drawing_SetTextStyleFontSize(txtStyle, 60); // 60 means font size for test
1698     EXPECT_EQ(OH_Drawing_TextStyleGetFontSize(txtStyle), 60);
1699     EXPECT_EQ(OH_Drawing_TextStyleGetFontSize(nullptr), 0.0);
1700     OH_Drawing_SetTextStyleLetterSpacing(txtStyle, 20); // 20 means letter spacing for test
1701     EXPECT_EQ(OH_Drawing_TextStyleGetLetterSpacing(txtStyle), 20);
1702     EXPECT_EQ(OH_Drawing_TextStyleGetLetterSpacing(nullptr), 0.0);
1703     OH_Drawing_SetTextStyleWordSpacing(txtStyle, 80); // 80 means word spacing for test
1704     EXPECT_EQ(OH_Drawing_TextStyleGetWordSpacing(txtStyle), 80);
1705     EXPECT_EQ(OH_Drawing_TextStyleGetWordSpacing(nullptr), 0.0);
1706     OH_Drawing_SetTextStyleFontHeight(txtStyle, 0.0); // 0.0 means font height for test
1707     EXPECT_EQ(OH_Drawing_TextStyleGetFontHeight(txtStyle), 0.0);
1708     EXPECT_EQ(OH_Drawing_TextStyleGetFontHeight(nullptr), 0.0);
1709     bool halfLeading = true;
1710     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
1711     EXPECT_EQ(OH_Drawing_TextStyleGetHalfLeading(txtStyle), true);
1712     EXPECT_EQ(OH_Drawing_TextStyleGetHalfLeading(nullptr), false);
1713     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
1714     EXPECT_EQ(std::strcmp(OH_Drawing_TextStyleGetLocale(txtStyle), "en"), 0);
1715     EXPECT_EQ(OH_Drawing_TextStyleGetLocale(nullptr) == nullptr, true);
1716 }
1717 
1718 /*
1719  * @tc.name: OH_Drawing_TypographyTest051
1720  * @tc.desc: test for getting line info for text typography
1721  * @tc.type: FUNC
1722  */
1723 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest051, TestSize.Level1)
1724 {
1725     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
1726     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1727     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
1728         OH_Drawing_CreateFontCollection());
1729     OH_Drawing_RectStyle_Info rectStyleInfo = {1, 1.5, 1.5, 1.5, 1.5}; // 1.5 means corner radius for test
1730     int styleId = 1; // 1 means styleId for test
1731     OH_Drawing_TextStyleSetBackgroundRect(txtStyle, nullptr, styleId);
1732     OH_Drawing_TextStyleSetBackgroundRect(nullptr, &rectStyleInfo, styleId);
1733     OH_Drawing_TextStyleSetBackgroundRect(txtStyle, &rectStyleInfo, styleId);
1734     uint32_t symbol = 2; // 2 means symbol for test
1735     OH_Drawing_TypographyHandlerAddSymbol(handler, symbol);
1736     OH_Drawing_TypographyHandlerAddSymbol(nullptr, symbol);
1737     const char* key1 = "宋体";
1738     int value1 = 1; // 1 for test
1739     OH_Drawing_TextStyleAddFontFeature(nullptr, key1, value1);
1740     OH_Drawing_TextStyleAddFontFeature(txtStyle, nullptr, value1);
1741     OH_Drawing_TextStyleAddFontFeature(txtStyle, key1, value1);
1742     const char* key2 = "斜体";
1743     int value2 = 2; // 2 for test
1744     OH_Drawing_TextStyleAddFontFeature(txtStyle, key2, value2);
1745     const char* key3 = "方体";
1746     int value3 = 3; // 3 for test
1747     OH_Drawing_TextStyleAddFontFeature(txtStyle, key3, value3);
1748     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatureSize(txtStyle), 3); // 3 means font feature size for test
1749     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatureSize(nullptr), 0);
1750     OH_Drawing_FontFeature* fontFeaturesArray = OH_Drawing_TextStyleGetFontFeatures(txtStyle);
1751     EXPECT_EQ(fontFeaturesArray != nullptr, true);
1752     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatures(nullptr) == nullptr, true);
1753     OH_Drawing_TextStyleDestroyFontFeatures(fontFeaturesArray, OH_Drawing_TextStyleGetFontFeatureSize(txtStyle));
1754     OH_Drawing_TextStyleDestroyFontFeatures(nullptr, OH_Drawing_TextStyleGetFontFeatureSize(txtStyle));
1755     OH_Drawing_TextStyleClearFontFeature(txtStyle);
1756     OH_Drawing_TextStyleClearFontFeature(nullptr);
1757     EXPECT_EQ(OH_Drawing_TextStyleGetFontFeatureSize(txtStyle), 0);
1758     double lineShift = 1.5; // 1.5 means baseline shift for test
1759     OH_Drawing_TextStyleSetBaselineShift(nullptr, lineShift);
1760     EXPECT_EQ(OH_Drawing_TextStyleGetBaselineShift(nullptr), 0.0);
1761     OH_Drawing_TextStyleSetBaselineShift(txtStyle, lineShift);
1762     EXPECT_EQ(OH_Drawing_TextStyleGetBaselineShift(txtStyle), 1.5);
1763 }
1764 
1765 /*
1766  * @tc.name: OH_Drawing_TypographyTest052
1767  * @tc.desc: test for setting the mode of leading over and under text
1768  * @tc.type: FUNC
1769  */
1770 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest052, TestSize.Level1)
1771 {
1772     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1773     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_ALL);
1774     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::ALL);
1775     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_FIRST_ASCENT);
1776     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::DISABLE_FIRST_ASCENT);
1777     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_LAST_ASCENT);
1778     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::DISABLE_LAST_ASCENT);
1779     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_ALL);
1780     EXPECT_EQ(ConvertToOriginalText(typoStyle)->textHeightBehavior, TextHeightBehavior::DISABLE_ALL);
1781 }
1782 
1783 /*
1784  * @tc.name: OH_Drawing_TypographyTest053
1785  * @tc.desc: test for getting the mode of leading over and under text
1786  * @tc.type: FUNC
1787  */
1788 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest053, TestSize.Level1)
1789 {
1790     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(nullptr) == TEXT_HEIGHT_ALL, true);
1791     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1792     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_ALL);
1793     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle) == TEXT_HEIGHT_ALL, true);
1794     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_FIRST_ASCENT);
1795     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle) == TEXT_HEIGHT_DISABLE_FIRST_ASCENT, true);
1796     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_LAST_ASCENT);
1797     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle) == TEXT_HEIGHT_DISABLE_LAST_ASCENT, true);
1798     OH_Drawing_TypographyTextSetHeightBehavior(typoStyle, TEXT_HEIGHT_DISABLE_ALL);
1799     EXPECT_EQ(OH_Drawing_TypographyTextGetHeightBehavior(typoStyle) == TEXT_HEIGHT_DISABLE_ALL, true);
1800 }
1801 
1802 /*
1803  * @tc.name: OH_Drawing_TypographyTest054
1804  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1805  * @tc.type: FUNC
1806  */
1807 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest054, TestSize.Level1)
1808 {
1809     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1810     OH_Drawing_FontCollection* fontCollection = OH_Drawing_CreateFontCollection();
1811     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);
1812     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1813     OH_Drawing_TypographyMarkDirty(typography);
1814     OH_Drawing_TypographyMarkDirty(nullptr);
1815     OH_Drawing_DestroyTypographyStyle(typoStyle);
1816     OH_Drawing_DestroyFontCollection(fontCollection);
1817     OH_Drawing_DestroyTypographyHandler(handler);
1818     OH_Drawing_DestroyTypography(typography);
1819     typoStyle = nullptr;
1820     fontCollection = nullptr;
1821     handler = nullptr;
1822     typography = nullptr;
1823     EXPECT_TRUE(typoStyle == nullptr);
1824     EXPECT_TRUE(fontCollection == nullptr);
1825     EXPECT_TRUE(handler == nullptr);
1826     EXPECT_TRUE(typography == nullptr);
1827 }
1828 
1829 /*
1830  * @tc.name: OH_Drawing_TypographyTest055
1831  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1832  * @tc.type: FUNC
1833  */
1834 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest055, TestSize.Level1)
1835 {
1836     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1837     OH_Drawing_FontCollection* fontCollection = OH_Drawing_CreateFontCollection();
1838     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);
1839     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1840     int32_t result = OH_Drawing_TypographyGetUnresolvedGlyphsCount(typography);
1841     EXPECT_TRUE(result != 0);
1842     result = OH_Drawing_TypographyGetUnresolvedGlyphsCount(nullptr);
1843     EXPECT_TRUE(result == 0);
1844     OH_Drawing_DestroyTypographyStyle(typoStyle);
1845     OH_Drawing_DestroyFontCollection(fontCollection);
1846     OH_Drawing_DestroyTypographyHandler(handler);
1847     OH_Drawing_DestroyTypography(typography);
1848     typoStyle = nullptr;
1849     fontCollection = nullptr;
1850     handler = nullptr;
1851     typography = nullptr;
1852     EXPECT_TRUE(typoStyle == nullptr);
1853     EXPECT_TRUE(fontCollection == nullptr);
1854     EXPECT_TRUE(handler == nullptr);
1855     EXPECT_TRUE(typography == nullptr);
1856 }
1857 
1858 /*
1859  * @tc.name: OH_Drawing_TypographyTest056
1860  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1861  * @tc.type: FUNC
1862  */
1863 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest056, TestSize.Level1)
1864 {
1865     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1866     OH_Drawing_FontCollection* fontCollection = OH_Drawing_CreateFontCollection();
1867     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);
1868     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
1869     size_t from = 10; // 10 means font size for test
1870     size_t to = 11; // 11 means font size for test
1871     float fontSize = 1.0; // 1.0 means font size for test
1872     OH_Drawing_TypographyUpdateFontSize(typography, from, to, fontSize);
1873     OH_Drawing_TypographyUpdateFontSize(nullptr, from, to, fontSize);
1874     OH_Drawing_DestroyTypographyStyle(typoStyle);
1875     OH_Drawing_DestroyFontCollection(fontCollection);
1876     OH_Drawing_DestroyTypographyHandler(handler);
1877     OH_Drawing_DestroyTypography(typography);
1878     typoStyle = nullptr;
1879     fontCollection = nullptr;
1880     handler = nullptr;
1881     typography = nullptr;
1882     EXPECT_TRUE(typoStyle == nullptr);
1883     EXPECT_TRUE(fontCollection == nullptr);
1884     EXPECT_TRUE(handler == nullptr);
1885     EXPECT_TRUE(typography == nullptr);
1886 }
1887 
1888 /*
1889  * @tc.name: OH_Drawing_TypographyTest057
1890  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1891  * @tc.type: FUNC
1892  */
1893 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest057, TestSize.Level1)
1894 {
1895     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1896     bool useLineStyle = true;
1897     OH_Drawing_SetTypographyTextUseLineStyle(typoStyle, useLineStyle);
1898     bool result = OH_Drawing_TypographyTextGetLineStyle(typoStyle);
1899     EXPECT_TRUE(result == true);
1900     result = OH_Drawing_TypographyTextGetLineStyle(nullptr);
1901     EXPECT_TRUE(result == false);
1902     OH_Drawing_DestroyTypographyStyle(typoStyle);
1903     typoStyle = nullptr;
1904     EXPECT_TRUE(typoStyle == nullptr);
1905 }
1906 
1907 /*
1908  * @tc.name: OH_Drawing_TypographyTest058
1909  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1910  * @tc.type: FUNC
1911  */
1912 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest058, TestSize.Level1)
1913 {
1914     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1915     int weight = FONT_WEIGHT_100;
1916     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, weight);
1917     OH_Drawing_FontWeight result = OH_Drawing_TypographyTextlineStyleGetFontWeight(typoStyle);
1918     EXPECT_TRUE(result == FONT_WEIGHT_100);
1919     result = OH_Drawing_TypographyTextlineStyleGetFontWeight(nullptr);
1920     EXPECT_TRUE(result == FONT_WEIGHT_400);
1921     OH_Drawing_DestroyTypographyStyle(typoStyle);
1922     typoStyle = nullptr;
1923     EXPECT_TRUE(typoStyle == nullptr);
1924 }
1925 
1926 /*
1927  * @tc.name: OH_Drawing_TypographyTest059
1928  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1929  * @tc.type: FUNC
1930  */
1931 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest059, TestSize.Level1)
1932 {
1933     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1934     int fontStyle = FONT_STYLE_ITALIC;
1935     OH_Drawing_SetTypographyTextLineStyleFontStyle(typoStyle, fontStyle);
1936     OH_Drawing_FontStyle result = OH_Drawing_TypographyTextlineStyleGetFontStyle(typoStyle);
1937     EXPECT_TRUE(result == FONT_STYLE_ITALIC);
1938     result = OH_Drawing_TypographyTextlineStyleGetFontStyle(nullptr);
1939     EXPECT_TRUE(result == FONT_STYLE_NORMAL);
1940     OH_Drawing_DestroyTypographyStyle(typoStyle);
1941     typoStyle = nullptr;
1942     EXPECT_TRUE(typoStyle == nullptr);
1943 }
1944 
1945 /*
1946  * @tc.name: OH_Drawing_TypographyTest060
1947  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1948  * @tc.type: FUNC
1949  */
1950 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest060, TestSize.Level1)
1951 {
1952     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1953     size_t fontNum = 1; // 1 means font number for test
1954     const char* fontFamilies[] = {"Roboto"};
1955     int fontFamiliesNumber = 1; // 1 means font families number for test
1956     OH_Drawing_SetTypographyTextLineStyleFontFamilies(typoStyle, fontFamiliesNumber, fontFamilies);
1957     char** result = OH_Drawing_TypographyTextlineStyleGetFontFamilies(typoStyle, &fontNum);
1958     EXPECT_TRUE(result != nullptr);
1959     result = OH_Drawing_TypographyTextlineStyleGetFontFamilies(nullptr, &fontNum);
1960     EXPECT_TRUE(result == nullptr);
1961     OH_Drawing_TypographyTextlineStyleDestroyFontFamilies(result, fontNum);
1962     OH_Drawing_DestroyTypographyStyle(typoStyle);
1963     typoStyle = nullptr;
1964     EXPECT_TRUE(typoStyle == nullptr);
1965 }
1966 
1967 /*
1968  * @tc.name: OH_Drawing_TypographyTest061
1969  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1970  * @tc.type: FUNC
1971  */
1972 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest061, TestSize.Level1)
1973 {
1974     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1975     double result = OH_Drawing_TypographyTextlineStyleGetFontSize(typoStyle);
1976     // 14.0 Fontsize default value
1977     EXPECT_TRUE(result == 14.0);
1978     result = OH_Drawing_TypographyTextlineStyleGetFontSize(nullptr);
1979     EXPECT_TRUE(result == 0);
1980     OH_Drawing_DestroyTypographyStyle(typoStyle);
1981     typoStyle = nullptr;
1982     EXPECT_TRUE(typoStyle == nullptr);
1983 }
1984 
1985 /*
1986  * @tc.name: OH_Drawing_TypographyTest062
1987  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
1988  * @tc.type: FUNC
1989  */
1990 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest062, TestSize.Level1)
1991 {
1992     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
1993     double result = OH_Drawing_TypographyTextlineStyleGetHeightScale(typoStyle);
1994     EXPECT_TRUE(result == 1.0); // 1.0 means enable the font height for line styles in text layout only
1995     result = OH_Drawing_TypographyTextlineStyleGetHeightScale(nullptr);
1996     EXPECT_TRUE(result == 0);
1997     OH_Drawing_DestroyTypographyStyle(typoStyle);
1998     typoStyle = nullptr;
1999     EXPECT_TRUE(typoStyle == nullptr);
2000 }
2001 
2002 /*
2003  * @tc.name: OH_Drawing_TypographyTest063
2004  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2005  * @tc.type: FUNC
2006  */
2007 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest063, TestSize.Level1)
2008 {
2009     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2010     // 2.0 measn font height for test
2011     double lineStyleFontHeight = 2.0;
2012     OH_Drawing_SetTypographyTextLineStyleFontHeight(typoStyle, lineStyleFontHeight);
2013     bool result = OH_Drawing_TypographyTextlineStyleGetHeightOnly(typoStyle);
2014     EXPECT_TRUE(result == true);
2015     result = OH_Drawing_TypographyTextlineStyleGetHeightOnly(nullptr);
2016     EXPECT_TRUE(result == false);
2017     OH_Drawing_DestroyTypographyStyle(typoStyle);
2018     typoStyle = nullptr;
2019     EXPECT_TRUE(typoStyle == nullptr);
2020 }
2021 
2022 /*
2023  * @tc.name: OH_Drawing_TypographyTest064
2024  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2025  * @tc.type: FUNC
2026  */
2027 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest064, TestSize.Level1)
2028 {
2029     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2030     bool lineStyleHalfLeading = true;
2031     OH_Drawing_SetTypographyTextLineStyleHalfLeading(typoStyle, lineStyleHalfLeading);
2032     bool result = OH_Drawing_TypographyTextlineStyleGetHalfLeading(typoStyle);
2033     EXPECT_TRUE(result == true);
2034     result = OH_Drawing_TypographyTextlineStyleGetHalfLeading(nullptr);
2035     EXPECT_TRUE(result == false);
2036     OH_Drawing_DestroyTypographyStyle(typoStyle);
2037     typoStyle = nullptr;
2038     EXPECT_TRUE(typoStyle == nullptr);
2039 }
2040 
2041 /*
2042  * @tc.name: OH_Drawing_TypographyTest065
2043  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2044  * @tc.type: FUNC
2045  */
2046 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest065, TestSize.Level1)
2047 {
2048     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2049     double result = OH_Drawing_TypographyTextlineStyleGetSpacingScale(typoStyle);
2050     // -1.0 for test
2051     EXPECT_TRUE(result == -1.0);
2052     result = OH_Drawing_TypographyTextlineStyleGetSpacingScale(nullptr);
2053     EXPECT_TRUE(result == 0);
2054     OH_Drawing_DestroyTypographyStyle(typoStyle);
2055     typoStyle = nullptr;
2056     EXPECT_TRUE(typoStyle == nullptr);
2057 }
2058 
2059 /*
2060  * @tc.name: OH_Drawing_TypographyTest066
2061  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2062  * @tc.type: FUNC
2063  */
2064 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest066, TestSize.Level1)
2065 {
2066     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2067     int direction = TEXT_DIRECTION_RTL;
2068     OH_Drawing_SetTypographyTextDirection(typoStyle, direction);
2069     OH_Drawing_TextDirection result = OH_Drawing_TypographyGetTextDirection(typoStyle);
2070     EXPECT_TRUE(result == TEXT_DIRECTION_RTL);
2071     result = OH_Drawing_TypographyGetTextDirection(nullptr);
2072     EXPECT_TRUE(result == TEXT_DIRECTION_LTR);
2073     OH_Drawing_DestroyTypographyStyle(typoStyle);
2074     typoStyle = nullptr;
2075     EXPECT_TRUE(typoStyle == nullptr);
2076 }
2077 
2078 /*
2079  * @tc.name: OH_Drawing_TypographyTest067
2080  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2081  * @tc.type: FUNC
2082  */
2083 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest067, TestSize.Level1)
2084 {
2085     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2086     size_t result = OH_Drawing_TypographyGetTextMaxLines(typoStyle);
2087     EXPECT_TRUE(result != 0);
2088     result = OH_Drawing_TypographyGetTextMaxLines(nullptr);
2089     EXPECT_TRUE(result == 0);
2090     OH_Drawing_DestroyTypographyStyle(typoStyle);
2091     typoStyle = nullptr;
2092     EXPECT_TRUE(typoStyle == nullptr);
2093 }
2094 
2095 /*
2096  * @tc.name: OH_Drawing_TypographyTest068
2097  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2098  * @tc.type: FUNC
2099  */
2100 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest068, TestSize.Level1)
2101 {
2102     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2103     char* result = OH_Drawing_TypographyGetTextEllipsis(typoStyle);
2104     EXPECT_TRUE(result != nullptr);
2105     result = OH_Drawing_TypographyGetTextEllipsis(nullptr);
2106     EXPECT_TRUE(result == nullptr);
2107     OH_Drawing_TypographyDestroyEllipsis(result);
2108     OH_Drawing_DestroyTypographyStyle(typoStyle);
2109     typoStyle = nullptr;
2110     EXPECT_TRUE(typoStyle == nullptr);
2111 }
2112 
2113 /*
2114  * @tc.name: OH_Drawing_TypographyTest069
2115  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2116  * @tc.type: FUNC
2117  */
2118 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest069, TestSize.Level1)
2119 {
2120     OH_Drawing_TypographyStyle* from = OH_Drawing_CreateTypographyStyle();
2121     OH_Drawing_TypographyStyle* to = OH_Drawing_CreateTypographyStyle();
2122     bool result = OH_Drawing_TypographyStyleEquals(from, to);
2123     EXPECT_TRUE(result == true);
2124     result = OH_Drawing_TypographyStyleEquals(nullptr, to);
2125     EXPECT_TRUE(result == false);
2126     result = OH_Drawing_TypographyStyleEquals(from, nullptr);
2127     EXPECT_TRUE(result == false);
2128     OH_Drawing_DestroyTypographyStyle(from);
2129     OH_Drawing_DestroyTypographyStyle(to);
2130     from = nullptr;
2131     to = nullptr;
2132     EXPECT_TRUE(from == nullptr);
2133     EXPECT_TRUE(to == nullptr);
2134 }
2135 
2136 /*
2137  * @tc.name: OH_Drawing_TypographyTest070
2138  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2139  * @tc.type: FUNC
2140  */
2141 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest070, TestSize.Level1)
2142 {
2143     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2144     OH_Drawing_SetTypographyTextLineStyleOnly(typoStyle, true);
2145     bool result = OH_Drawing_TypographyTextlineGetStyleOnly(typoStyle);
2146     EXPECT_TRUE(result == true);
2147     result = OH_Drawing_TypographyTextlineGetStyleOnly(nullptr);
2148     EXPECT_TRUE(result == false);
2149     OH_Drawing_DestroyTypographyStyle(typoStyle);
2150     typoStyle = nullptr;
2151     EXPECT_TRUE(typoStyle == nullptr);
2152 }
2153 
2154 /*
2155  * @tc.name: OH_Drawing_TypographyTest071
2156  * @tc.desc: test for halfleading, uselinestyle linestyleonly of text typography
2157  * @tc.type: FUNC
2158  */
2159 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest071, TestSize.Level1)
2160 {
2161     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2162     int align = TEXT_ALIGN_RIGHT;
2163     OH_Drawing_SetTypographyTextAlign(typoStyle, align);
2164     OH_Drawing_TextAlign result = OH_Drawing_TypographyGetTextAlign(typoStyle);
2165     EXPECT_TRUE(result == TEXT_ALIGN_RIGHT);
2166     result= OH_Drawing_TypographyGetTextAlign(nullptr);
2167     EXPECT_TRUE(result == TEXT_ALIGN_LEFT);
2168     OH_Drawing_DestroyTypographyStyle(typoStyle);
2169     typoStyle = nullptr;
2170     EXPECT_TRUE(typoStyle == nullptr);
2171 }
2172 
2173 /*
2174  * @tc.name: OH_Drawing_TypographyTest072
2175  * @tc.desc: test for create and releases the memory occupied by system font configuration information
2176  * @tc.type: FUNC
2177  */
2178 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest072, TestSize.Level1)
2179 {
2180     OH_Drawing_FontConfigInfoErrorCode code = ERROR_FONT_CONFIG_INFO_UNKNOWN;
2181     OH_Drawing_FontConfigInfo* configJsonInfo = OH_Drawing_GetSystemFontConfigInfo(&code);
2182     if (configJsonInfo != nullptr) {
2183         EXPECT_EQ(code, SUCCESS_FONT_CONFIG_INFO);
2184     } else {
2185         EXPECT_NE(code, SUCCESS_FONT_CONFIG_INFO);
2186     }
2187     OH_Drawing_DestroySystemFontConfigInfo(configJsonInfo);
2188     configJsonInfo = nullptr;
2189 }
2190 
2191 /*
2192  * @tc.name: OH_Drawing_TypographyTest073
2193  * @tc.desc: test for getting all font metrics array from current line
2194  * @tc.type: FUNC
2195  */
2196 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest073, TestSize.Level1)
2197 {
2198     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2199     EXPECT_TRUE(typoStyle != nullptr);
2200     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2201     EXPECT_TRUE(txtStyle != nullptr);
2202     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2203         OH_Drawing_CreateFontCollection());
2204     EXPECT_TRUE(handler != nullptr);
2205     size_t charNumber = 0;
2206     const char* text = "OpenHarmony\n";
2207     OH_Drawing_TypographyHandlerAddText(handler, text);
2208     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2209     EXPECT_TRUE(typography != nullptr);
2210     OH_Drawing_Font_Metrics* StartLineFont = OH_Drawing_TypographyGetLineFontMetrics(typography, 1, &charNumber);
2211     EXPECT_TRUE(StartLineFont == nullptr);
2212     OH_Drawing_TypographyDestroyLineFontMetrics(StartLineFont);
2213     OH_Drawing_DestroyTypography(typography);
2214     OH_Drawing_DestroyTypographyHandler(handler);
2215     OH_Drawing_DestroyTypographyStyle(typoStyle);
2216     OH_Drawing_DestroyTextStyle(txtStyle);
2217 }
2218 
2219 /*
2220  * @tc.name: OH_Drawing_TypographyTest074
2221  * @tc.desc: test for getting and setting strut style
2222  * @tc.type: FUNC
2223  */
2224 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest074, TestSize.Level1)
2225 {
2226     OH_Drawing_TypographyStyle *typoStyle = OH_Drawing_CreateTypographyStyle();
2227     OH_Drawing_StrutStyle *strutstyle = new OH_Drawing_StrutStyle();
2228     strutstyle->weight = FONT_WEIGHT_400;
2229     strutstyle->style = FONT_STYLE_ITALIC;
2230     // 17.0 For size
2231     strutstyle->size = 17.0;
2232     // 2.0 For heightScale
2233     strutstyle->heightScale = 2;
2234     strutstyle->heightOverride = true;
2235     strutstyle->halfLeading = true;
2236     // 3.0 For leading
2237     strutstyle->leading = 3.0;
2238     strutstyle->forceStrutHeight = true;
2239     // 4 For families size
2240     strutstyle->familiesSize = 4;
2241     strutstyle->families = (char**)malloc(strutstyle->familiesSize*sizeof(char*));
2242     const char *temp[] = {"1", "2", "3", "4"};
2243     for (int i = 0; i < strutstyle->familiesSize; i++) {
2244         // 2 For families member size
2245         strutstyle->families[i] = (char*)malloc(2*sizeof(char));
2246         strcpy_s(strutstyle->families[i], 2, temp[i]);
2247     }
2248     OH_Drawing_SetTypographyStyleTextStrutStyle(typoStyle, strutstyle);
2249     EXPECT_EQ(OH_Drawing_TypographyStyleGetStrutStyle(typoStyle) != nullptr, true);
2250     OH_Drawing_TypographyStyleDestroyStrutStyle(strutstyle);
2251     OH_Drawing_DestroyTypographyStyle(typoStyle);
2252 }
2253 
2254 /*
2255  * @tc.name: OH_Drawing_TypographyTest075
2256  * @tc.desc: test for sets and gets isPlaceholder for TextStyle objects
2257  * @tc.type: FUNC
2258  */
2259 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest075, TestSize.Level1)
2260 {
2261     EXPECT_EQ(OH_Drawing_TextStyleIsPlaceholder(nullptr), false);
2262     OH_Drawing_TextStyle *txtStyle = OH_Drawing_CreateTextStyle();
2263     EXPECT_EQ(OH_Drawing_TextStyleIsPlaceholder(txtStyle), false);
2264     OH_Drawing_TextStyleSetPlaceholder(nullptr);
2265     OH_Drawing_TextStyleSetPlaceholder(txtStyle);
2266     EXPECT_EQ(OH_Drawing_TextStyleIsPlaceholder(txtStyle), true);
2267     EXPECT_EQ(ConvertToOriginalText(txtStyle)->isPlaceholder, true);
2268     OH_Drawing_DestroyTextStyle(txtStyle);
2269 }
2270 
2271 /*
2272  * @tc.name: OH_Drawing_TypographyTest076
2273  * @tc.desc: test for the two TextStyle objects have matching properties
2274  * @tc.type: FUNC
2275  */
2276 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest076, TestSize.Level1)
2277 {
2278     OH_Drawing_TextStyle *txtStyle = OH_Drawing_CreateTextStyle();
2279     OH_Drawing_TextStyle *txtStyleCompare = OH_Drawing_CreateTextStyle();
2280     bool result = OH_Drawing_TextStyleIsAttributeMatched(txtStyle, txtStyleCompare, TEXT_STYLE_ALL_ATTRIBUTES);
2281     EXPECT_TRUE(result == true);
2282     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
2283     result = OH_Drawing_TextStyleIsAttributeMatched(txtStyle, txtStyleCompare, TEXT_STYLE_ALL_ATTRIBUTES);
2284     EXPECT_TRUE(result == false);
2285     EXPECT_EQ(OH_Drawing_TextStyleIsAttributeMatched(nullptr, txtStyleCompare, TEXT_STYLE_ALL_ATTRIBUTES), false);
2286     EXPECT_EQ(OH_Drawing_TextStyleIsAttributeMatched(txtStyle, nullptr, TEXT_STYLE_ALL_ATTRIBUTES), false);
2287     OH_Drawing_DestroyTextStyle(txtStyle);
2288     OH_Drawing_DestroyTextStyle(txtStyleCompare);
2289 }
2290 
2291 /*
2292  * @tc.name: OH_Drawing_TypographyTest077
2293  * @tc.desc: test for strutstyle equals
2294  * @tc.type: FUNC
2295  */
2296 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest077, TestSize.Level1)
2297 {
2298     OH_Drawing_StrutStyle* from = new OH_Drawing_StrutStyle();
2299     OH_Drawing_StrutStyle* to = new OH_Drawing_StrutStyle();
2300     bool result = OH_Drawing_TypographyStyleStrutStyleEquals(from, to);
2301     EXPECT_TRUE(result == true);
2302     result = OH_Drawing_TypographyStyleStrutStyleEquals(nullptr, to);
2303     EXPECT_TRUE(result == false);
2304     result = OH_Drawing_TypographyStyleStrutStyleEquals(from, nullptr);
2305     EXPECT_TRUE(result == false);
2306     OH_Drawing_TypographyStyleDestroyStrutStyle(from);
2307     OH_Drawing_TypographyStyleDestroyStrutStyle(to);
2308     from = nullptr;
2309     to = nullptr;
2310     EXPECT_TRUE(from == nullptr);
2311     EXPECT_TRUE(to == nullptr);
2312 }
2313 
2314 /*
2315  * @tc.name: OH_Drawing_TypographyTest078
2316  * @tc.desc: test for gets the typoStyle alignment mode and whether to enable text prompts
2317  * @tc.type: FUNC
2318  */
2319 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest078, TestSize.Level1)
2320 {
2321     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2322     EXPECT_EQ(OH_Drawing_TypographyStyleGetEffectiveAlignment(typoStyle), TEXT_ALIGN_LEFT);
2323     EXPECT_EQ(OH_Drawing_TypographyStyleIsHintEnabled(typoStyle), false);
2324     OH_Drawing_DestroyTypographyStyle(typoStyle);
2325 }
2326 
2327 /*
2328  * @tc.name: OH_Drawing_TypographyTest079
2329  * @tc.desc: test for setting the hinting of text typography
2330  * @tc.type: FUNC
2331  */
2332 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest079, TestSize.Level1)
2333 {
2334     OH_Drawing_TypographyStyle *typoStyle = OH_Drawing_CreateTypographyStyle();
2335     OH_Drawing_TypographyStyleSetHintsEnabled(typoStyle, true);
2336     EXPECT_EQ(ConvertToOriginalText(typoStyle)->hintingIsOn, true);
2337     OH_Drawing_DestroyTypographyStyle(typoStyle);
2338 }
2339 
2340 /*
2341  * @tc.name: OH_Drawing_TypographyTest080
2342  * @tc.desc: test for whether two TextStyle objects are equal
2343  * @tc.type: FUNC
2344  */
2345 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest080, TestSize.Level1)
2346 {
2347     OH_Drawing_TextStyle *txtStyle = OH_Drawing_CreateTextStyle();
2348     OH_Drawing_TextStyle *txtStyleCompare = OH_Drawing_CreateTextStyle();
2349     bool result = OH_Drawing_TextStyleIsEqual(txtStyle, txtStyleCompare);
2350     EXPECT_TRUE(result == true);
2351 
2352     OH_Drawing_SetTextStyleColor(txtStyle, 1);
2353     result = OH_Drawing_TextStyleIsEqual(txtStyle, txtStyleCompare);
2354     EXPECT_TRUE(result == false);
2355     OH_Drawing_SetTextStyleColor(txtStyleCompare, 1);
2356     result = OH_Drawing_TextStyleIsEqual(txtStyle, txtStyleCompare);
2357     EXPECT_TRUE(result == true);
2358     EXPECT_EQ(OH_Drawing_TextStyleIsEqual(nullptr, txtStyleCompare), false);
2359     EXPECT_EQ(OH_Drawing_TextStyleIsEqual(txtStyle, nullptr), false);
2360     EXPECT_EQ(OH_Drawing_TextStyleIsEqual(nullptr, nullptr), true);
2361     OH_Drawing_DestroyTextStyle(txtStyle);
2362     OH_Drawing_DestroyTextStyle(txtStyleCompare);
2363 }
2364 
2365 /*
2366  * @tc.name: OH_Drawing_TypographyTest081
2367  * @tc.desc: test for getting and setting text style
2368  * @tc.type: FUNC
2369  */
2370 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest081, TestSize.Level1)
2371 {
2372     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2373     EXPECT_NE(txtStyle, nullptr);
2374     OH_Drawing_FontStyleStruct normalStyle;
2375     normalStyle.weight = FONT_WEIGHT_400;
2376     normalStyle.width = FONT_WIDTH_NORMAL;
2377     normalStyle.slant = FONT_STYLE_NORMAL;
2378     OH_Drawing_SetTextStyleFontStyleStruct(txtStyle, normalStyle);
2379 
2380     OH_Drawing_FontStyleStruct style = OH_Drawing_TextStyleGetFontStyleStruct(txtStyle);
2381     EXPECT_EQ(style.weight, normalStyle.weight);
2382     EXPECT_EQ(style.width, normalStyle.width);
2383     EXPECT_EQ(style.slant, normalStyle.slant);
2384     OH_Drawing_DestroyTextStyle(txtStyle);
2385 }
2386 
2387 /*
2388  * @tc.name: OH_Drawing_TypographyTest082
2389  * @tc.desc: test for getting and setting typography style
2390  * @tc.type: FUNC
2391  */
2392 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest082, TestSize.Level1)
2393 {
2394     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2395     EXPECT_NE(typoStyle, nullptr);
2396     OH_Drawing_FontStyleStruct normalStyle;
2397     normalStyle.weight = FONT_WEIGHT_400;
2398     normalStyle.width = FONT_WIDTH_NORMAL;
2399     normalStyle.slant = FONT_STYLE_NORMAL;
2400     OH_Drawing_SetTypographyStyleFontStyleStruct(typoStyle, normalStyle);
2401 
2402     OH_Drawing_FontStyleStruct style = OH_Drawing_TypographyStyleGetFontStyleStruct(typoStyle);
2403     EXPECT_EQ(style.weight, normalStyle.weight);
2404     EXPECT_EQ(style.width, normalStyle.width);
2405     EXPECT_EQ(style.slant, normalStyle.slant);
2406     OH_Drawing_DestroyTypographyStyle(typoStyle);
2407 }
2408 
2409 /*
2410  * @tc.name: OH_Drawing_TypographyTest083
2411  * @tc.desc: test for the font properties of two TextStyle objects are equal
2412  * @tc.type: FUNC
2413  */
2414 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest083, TestSize.Level1)
2415 {
2416     OH_Drawing_TextStyle *txtStyle = OH_Drawing_CreateTextStyle();
2417     OH_Drawing_TextStyle *txtStyleCompare = OH_Drawing_CreateTextStyle();
2418     OH_Drawing_SetTextStyleLocale(txtStyle, "en");
2419     OH_Drawing_SetTextStyleLocale(txtStyleCompare, "en");
2420     bool result = OH_Drawing_TextStyleIsEqualByFont(txtStyle, txtStyleCompare);
2421     EXPECT_TRUE(result == true);
2422 
2423     OH_Drawing_SetTextStyleLocale(txtStyle, "ch");
2424     result = OH_Drawing_TextStyleIsEqualByFont(txtStyle, txtStyleCompare);
2425     EXPECT_TRUE(result == false);
2426     EXPECT_EQ(OH_Drawing_TextStyleIsEqualByFont(nullptr, txtStyleCompare), false);
2427     EXPECT_EQ(OH_Drawing_TextStyleIsEqualByFont(txtStyle, nullptr), false);
2428     OH_Drawing_DestroyTextStyle(txtStyle);
2429     OH_Drawing_DestroyTextStyle(txtStyleCompare);
2430 }
2431 
2432 /*
2433  * @tc.name: OH_Drawing_TypographyTest084
2434  * @tc.desc: test for BREAK_STRATEGY_GREEDY
2435  * @tc.type: FUNC
2436  */
2437 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest084, TestSize.Level1)
2438 {
2439     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2440     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2441     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_GREEDY);
2442     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2443         OH_Drawing_CreateFontCollection());
2444     EXPECT_TRUE(handler != nullptr);
2445     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2446     const char* text = "breakStrategyTest breakStrategy breakStrategyGreedyTest";
2447     OH_Drawing_TypographyHandlerAddText(handler, text);
2448     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2449     // {1.2, 3.4} for unit test
2450     const float indents[] = {1.2, 3.4};
2451     OH_Drawing_TypographySetIndents(typography, 2, indents);
2452     // 300.0 for unit test
2453     double maxWidth = 300.0;
2454     OH_Drawing_TypographyLayout(typography, maxWidth);
2455     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
2456 }
2457 
2458 /*
2459  * @tc.name: OH_Drawing_TypographyTest085
2460  * @tc.desc: test for BREAK_STRATEGY_BALANCED
2461  * @tc.type: FUNC
2462  */
2463 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest085, TestSize.Level1)
2464 {
2465     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2466     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2467     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_BALANCED);
2468     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2469         OH_Drawing_CreateFontCollection());
2470     EXPECT_TRUE(handler != nullptr);
2471     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2472     const char* text = "breakStrategyTest breakStrategy breakStrategyBALANCEDTest";
2473     OH_Drawing_TypographyHandlerAddText(handler, text);
2474     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2475     // {1.2, 3.4} for unit test
2476     const float indents[] = {1.2, 3.4};
2477     OH_Drawing_TypographySetIndents(typography, 2, indents);
2478     // 300.0 for unit test
2479     double maxWidth = 300.0;
2480     OH_Drawing_TypographyLayout(typography, maxWidth);
2481     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
2482 }
2483 
2484 /*
2485  * @tc.name: OH_Drawing_TypographyTest086
2486  * @tc.desc: test for BREAK_STRATEGY_HIGH_QUALITY
2487  * @tc.type: FUNC
2488  */
2489 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest086, TestSize.Level1)
2490 {
2491     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2492     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2493     OH_Drawing_SetTypographyTextBreakStrategy(typoStyle, BREAK_STRATEGY_HIGH_QUALITY);
2494     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2495         OH_Drawing_CreateFontCollection());
2496     EXPECT_TRUE(handler != nullptr);
2497     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2498     const char* text = "breakStrategyTest breakStrategy breakStrategyHighQualityTest";
2499     OH_Drawing_TypographyHandlerAddText(handler, text);
2500     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2501     // {1.2, 3.4} for unit test
2502     const float indents[] = {1.2, 3.4};
2503     OH_Drawing_TypographySetIndents(typography, 2, indents);
2504     // 300.0 for unit test
2505     double maxWidth = 300.0;
2506     OH_Drawing_TypographyLayout(typography, maxWidth);
2507     EXPECT_EQ(maxWidth, OH_Drawing_TypographyGetMaxWidth(typography));
2508 }
2509 
2510 /*
2511  * @tc.name: OH_Drawing_TypographyTest089
2512  * @tc.desc: test for getting line  metrics for text typography
2513  * @tc.type: FUNC
2514  */
2515 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest089, TestSize.Level1)
2516 {
2517     OH_Drawing_Typography* typography = nullptr;
2518     OH_Drawing_LineMetrics* vectorMetrics = OH_Drawing_TypographyGetLineMetrics(typography);
2519     EXPECT_EQ(vectorMetrics == nullptr, true);
2520 }
2521 
2522 /*
2523  * @tc.name: OH_Drawing_TypographyTest090
2524  * @tc.desc: test for getting size of line metrics for text typography
2525  * @tc.type: FUNC
2526  */
2527 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest090, TestSize.Level1)
2528 {
2529     OH_Drawing_Typography* typography = nullptr;
2530     OH_Drawing_LineMetrics* vectorMetrics = OH_Drawing_TypographyGetLineMetrics(typography);
2531     EXPECT_EQ(vectorMetrics == nullptr, true);
2532     EXPECT_EQ(OH_Drawing_LineMetricsGetSize(vectorMetrics) == 0, true);
2533     OH_Drawing_DestroyLineMetrics(vectorMetrics);
2534 }
2535 
2536 /*
2537  * @tc.name: OH_Drawing_TypographyTest091
2538  * @tc.desc: test returning line metrics info for the line text typography
2539  * @tc.type: FUNC
2540  */
2541 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest091, TestSize.Level1)
2542 {
2543     OH_Drawing_Typography* typography = nullptr;
2544     OH_Drawing_LineMetrics* metrics = nullptr;
2545     EXPECT_EQ(OH_Drawing_TypographyGetLineMetricsAt(typography, 0, metrics), false);
2546     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2547     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2548         OH_Drawing_CreateFontCollection());
2549     typography = OH_Drawing_CreateTypography(handler);
2550     metrics = new OH_Drawing_LineMetrics();
2551     EXPECT_EQ(OH_Drawing_TypographyGetLineMetricsAt(typography, -1, metrics), false);
2552     OH_Drawing_DestroyTypography(typography);
2553     OH_Drawing_DestroyTypographyHandler(handler);
2554     delete metrics;
2555     metrics = nullptr;
2556 }
2557 
2558 /*
2559  * @tc.name: OH_Drawing_TypographyTest092
2560  * @tc.desc: test for getting indets of index for text typography
2561  * @tc.type: FUNC
2562  */
2563 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest092, TestSize.Level1)
2564 {
2565     OH_Drawing_Typography* typography = nullptr;
2566     EXPECT_EQ(0.0, OH_Drawing_TypographyGetIndentsWithIndex(typography, 1));
2567     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2568     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2569         OH_Drawing_CreateFontCollection());
2570     typography = OH_Drawing_CreateTypography(handler);
2571     EXPECT_EQ(0.0, OH_Drawing_TypographyGetIndentsWithIndex(typography, -1));
2572     // {1.2, 3.4} for unit test
2573     const float indents[] = {1.2, 3.4};
2574     OH_Drawing_TypographySetIndents(typography, 2, indents);
2575     int indexOutOfBounds = 3;
2576     EXPECT_EQ(indents[1], OH_Drawing_TypographyGetIndentsWithIndex(typography, indexOutOfBounds));
2577     OH_Drawing_DestroyTypography(typography);
2578     OH_Drawing_DestroyTypographyHandler(handler);
2579     OH_Drawing_DestroyTypographyStyle(typoStyle);
2580 }
2581 
2582 /*
2583  * @tc.name: OH_Drawing_TypographyTest093
2584  * @tc.desc: test for getting line font metrics for text typography
2585  * @tc.type: FUNC
2586  */
2587 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest093, TestSize.Level1)
2588 {
2589     size_t charNumber = 0;
2590     EXPECT_EQ(OH_Drawing_TypographyGetLineFontMetrics(nullptr, 1, &charNumber), nullptr);
2591     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2592     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2593         OH_Drawing_CreateFontCollection());
2594     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2595     EXPECT_EQ(OH_Drawing_TypographyGetLineFontMetrics(typography, 1, nullptr), nullptr);
2596     EXPECT_EQ(OH_Drawing_TypographyGetLineFontMetrics(typography, 0, &charNumber), nullptr);
2597     OH_Drawing_DestroyTypography(typography);
2598     OH_Drawing_DestroyTypographyHandler(handler);
2599     OH_Drawing_DestroyTypographyStyle(typoStyle);
2600 }
2601 
2602 /*
2603  * @tc.name: OH_Drawing_TypographyTest094
2604  * @tc.desc: test for setting font weight for text typography
2605  * @tc.type: FUNC
2606  */
2607 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest094, TestSize.Level1)
2608 {
2609     OH_Drawing_SetTypographyTextFontWeight(nullptr, FONT_WEIGHT_100);
2610     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2611     OH_Drawing_SetTypographyTextFontWeight(typoStyle, -1);
2612     EXPECT_EQ(ConvertToOriginalText(typoStyle)->fontWeight, FontWeight::W400);
2613     OH_Drawing_SetTypographyTextFontStyle(nullptr, FONT_STYLE_NORMAL);
2614     OH_Drawing_DestroyTypographyStyle(typoStyle);
2615 }
2616 
2617 /*
2618  * @tc.name: OH_Drawing_TypographyTest095
2619  * @tc.desc: test for setting font height for text typography
2620  * @tc.type: FUNC
2621  */
2622 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest095, TestSize.Level1)
2623 {
2624     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2625     // -1.2 for unit test
2626     OH_Drawing_SetTypographyTextFontHeight(typoStyle, -1.2);
2627     EXPECT_EQ(ConvertToOriginalText(typoStyle)->heightOnly, true);
2628     EXPECT_EQ(ConvertToOriginalText(typoStyle)->heightScale, 0);
2629 }
2630 
2631 /*
2632  * @tc.name: OH_Drawing_TypographyTest096
2633  * @tc.desc: test for setting half leading for text typography
2634  * @tc.type: FUNC
2635  */
2636 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest096, TestSize.Level1)
2637 {
2638     bool halfLeading = false;
2639     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2640     OH_Drawing_SetTypographyTextHalfLeading(typoStyle, halfLeading);
2641     EXPECT_EQ(ConvertToOriginalText(typoStyle)->halfLeading, false);
2642 }
2643 
2644 /*
2645  * @tc.name: OH_Drawing_TypographyTest097
2646  * @tc.desc: test for setting text line style font weight for text typography
2647  * @tc.type: FUNC
2648  */
2649 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest097, TestSize.Level1)
2650 {
2651     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2652     // -1 for unit test
2653     int weight = -1;
2654     OH_Drawing_SetTypographyTextLineStyleFontWeight(typoStyle, weight);
2655     EXPECT_EQ(ConvertToOriginalText(typoStyle)->lineStyleFontWeight, FontWeight::W400);
2656 }
2657 
2658 /*
2659  * @tc.name: OH_Drawing_TypographyTest098
2660  * @tc.desc: test for text line style getting font families for text typography
2661  * @tc.type: FUNC
2662  */
2663 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest098, TestSize.Level1)
2664 {
2665     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2666     char** result = OH_Drawing_TypographyTextlineStyleGetFontFamilies(typoStyle, nullptr);
2667     EXPECT_TRUE(result == nullptr);
2668 }
2669 
2670 /*
2671  * @tc.name: OH_Drawing_TypographyTest099
2672  * @tc.desc: test for text line style setting half leading for text typography
2673  * @tc.type: FUNC
2674  */
2675 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest099, TestSize.Level1)
2676 {
2677     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2678     bool lineStyleHalfLeading = false;
2679     OH_Drawing_SetTypographyTextLineStyleHalfLeading(typoStyle, lineStyleHalfLeading);
2680     bool result = OH_Drawing_TypographyTextlineStyleGetHalfLeading(typoStyle);
2681     EXPECT_TRUE(result == false);
2682 }
2683 
2684 /*
2685  * @tc.name: OH_Drawing_TypographyTest100
2686  * @tc.desc: test for getting style struct for text typography
2687  * @tc.type: FUNC
2688  */
2689 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest100, TestSize.Level1)
2690 {
2691     // 0.0 for unit test
2692     double lineShift = 0.0;
2693     EXPECT_EQ(OH_Drawing_TypographyStyleGetStrutStyle(nullptr) == nullptr, true);
2694     OH_Drawing_TextStyleSetBaselineShift(nullptr, lineShift);
2695     EXPECT_EQ(OH_Drawing_TextStyleGetBaselineShift(nullptr), 0.0);
2696     EXPECT_EQ(OH_Drawing_TypographyStyleGetEffectiveAlignment(nullptr), TEXT_ALIGN_START);
2697     EXPECT_EQ(OH_Drawing_TypographyStyleIsHintEnabled(nullptr), false);
2698 }
2699 
2700 /*
2701  * @tc.name: OH_Drawing_TypographyTest101
2702  * @tc.desc: test for getting font style struct for text typography
2703  * @tc.type: FUNC
2704  */
2705 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest101, TestSize.Level1)
2706 {
2707     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2708     EXPECT_NE(typoStyle, nullptr);
2709     OH_Drawing_FontStyleStruct normalStyle;
2710     normalStyle.weight = FONT_WEIGHT_900;
2711     normalStyle.width = FONT_WIDTH_ULTRA_EXPANDED;
2712     normalStyle.slant = FONT_STYLE_ITALIC;
2713     OH_Drawing_SetTypographyStyleFontStyleStruct(typoStyle, normalStyle);
2714 
2715     OH_Drawing_FontStyleStruct style = OH_Drawing_TypographyStyleGetFontStyleStruct(typoStyle);
2716     EXPECT_EQ(style.weight, FONT_WEIGHT_900);
2717     EXPECT_EQ(style.width, FONT_WIDTH_ULTRA_EXPANDED);
2718     EXPECT_EQ(style.slant, FONT_STYLE_ITALIC);
2719     OH_Drawing_DestroyTypographyStyle(typoStyle);
2720 }
2721 
2722 /*
2723  * @tc.name: OH_Drawing_TypographyTest102
2724  * @tc.desc: test for the font parser
2725  * @tc.type: FUNC
2726  */
2727 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest102, TestSize.Level1)
2728 {
2729     OH_Drawing_FontParser* parser = OH_Drawing_CreateFontParser();
2730     static const std::string FILE_NAME = "/system/fonts/visibility_list.json";
2731     std::ifstream fileStream(FILE_NAME.c_str());
2732     if (fileStream.is_open()) {
2733         size_t fontNum;
2734         char** list = OH_Drawing_FontParserGetSystemFontList(parser, &fontNum);
2735         EXPECT_EQ(list != nullptr, true);
2736         EXPECT_EQ(OH_Drawing_FontParserGetSystemFontList(nullptr, &fontNum) == nullptr, true);
2737         const char *name = "HarmonyOS Sans Digit";
2738         EXPECT_EQ(OH_Drawing_FontParserGetFontByName(parser, name) != nullptr, true);
2739         EXPECT_EQ(OH_Drawing_FontParserGetFontByName(nullptr, name) == nullptr, true);
2740         OH_Drawing_DestroySystemFontList(list, fontNum);
2741         OH_Drawing_DestroySystemFontList(nullptr, fontNum);
2742     }
2743     OH_Drawing_DestroyFontParser(parser);
2744 }
2745 
2746 /*
2747  * @tc.name: OH_Drawing_TypographyTest103
2748  * @tc.desc: test arc text offset
2749  * @tc.type: FUNC
2750  */
2751 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest104, TestSize.Level1)
2752 {
2753     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2754     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2755     OH_Drawing_TypographyCreate* handler =
2756         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2757     EXPECT_TRUE(handler != nullptr);
2758     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
2759     OH_Drawing_SetTextStyleFontSize(txtStyle, ARC_FONT_SIZE);
2760     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
2761     bool halfLeading = true;
2762     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
2763     const char* fontFamilies[] = { "Roboto" };
2764     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
2765     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2766     const char* text = "OpenHarmony\n";
2767     OH_Drawing_TypographyHandlerAddText(handler, text);
2768     OH_Drawing_TypographyHandlerPopTextStyle(handler);
2769     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2770     OH_Drawing_TypographyLayout(typography, MAX_WIDTH);
2771     OH_Drawing_Path* cPath = OH_Drawing_PathCreate();
2772     OH_Drawing_PathArcTo(cPath, LEFT_POS, LEFT_POS, RIGHT_POS, RIGHT_POS, 0, SWEEP_DEGREE);
2773 
2774     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
2775     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
2776     OH_Drawing_CanvasDrawPath(cCanvas, cPath);
2777     OH_Drawing_TypographyPaintOnPath(typography, cCanvas, cPath, ARC_FONT_SIZE, ARC_FONT_SIZE);
2778     OH_Drawing_Font_Metrics fontmetrics;
2779     EXPECT_EQ(OH_Drawing_TextStyleGetFontMetrics(typography, txtStyle, &fontmetrics), true);
2780     OH_Drawing_SetTypographyTextStyle(typoStyle, txtStyle);
2781     OH_Drawing_DestroyTypography(typography);
2782     OH_Drawing_DestroyTypographyHandler(handler);
2783     OH_Drawing_DestroyTypographyStyle(typoStyle);
2784     OH_Drawing_DestroyTextStyle(txtStyle);
2785     OH_Drawing_PathDestroy(cPath);
2786     OH_Drawing_CanvasDestroy(cCanvas);
2787 }
2788 
2789 /*
2790  * @tc.name: OH_Drawing_TypographyTest104
2791  * @tc.desc: test arc text drawing
2792  * @tc.type: FUNC
2793  */
2794 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest103, TestSize.Level1)
2795 {
2796     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2797     OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
2798     OH_Drawing_TypographyCreate* handler =
2799         OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection());
2800     EXPECT_TRUE(handler != nullptr);
2801     OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
2802     OH_Drawing_SetTextStyleFontSize(txtStyle, ARC_FONT_SIZE);
2803     OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
2804     bool halfLeading = true;
2805     OH_Drawing_SetTextStyleHalfLeading(txtStyle, halfLeading);
2806     const char* fontFamilies[] = { "Roboto" };
2807     OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
2808     OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
2809     const char* text = "OpenHarmony\n";
2810     OH_Drawing_TypographyHandlerAddText(handler, text);
2811     OH_Drawing_TypographyHandlerPopTextStyle(handler);
2812     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2813     OH_Drawing_TypographyLayout(typography, MAX_WIDTH);
2814     OH_Drawing_Path* cPath = OH_Drawing_PathCreate();
2815     OH_Drawing_PathArcTo(cPath, LEFT_POS, LEFT_POS, RIGHT_POS, RIGHT_POS, 0, SWEEP_DEGREE);
2816 
2817     OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
2818     OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
2819     OH_Drawing_CanvasDrawPath(cCanvas, cPath);
2820     OH_Drawing_TypographyPaintOnPath(typography, cCanvas, cPath, ARC_FONT_SIZE, ARC_FONT_SIZE);
2821     OH_Drawing_Font_Metrics fontmetrics;
2822     EXPECT_EQ(OH_Drawing_TextStyleGetFontMetrics(typography, txtStyle, &fontmetrics), true);
2823     OH_Drawing_SetTypographyTextStyle(typoStyle, txtStyle);
2824     OH_Drawing_DestroyTypography(typography);
2825     OH_Drawing_DestroyTypographyHandler(handler);
2826     OH_Drawing_DestroyTypographyStyle(typoStyle);
2827     OH_Drawing_DestroyTextStyle(txtStyle);
2828     OH_Drawing_PathDestroy(cPath);
2829     OH_Drawing_CanvasDestroy(cCanvas);
2830 }
2831 
2832 /*
2833  * @tc.name: OH_Drawing_TypographyTest105
2834  * @tc.desc: test for the text box
2835  * @tc.type: FUNC
2836  */
2837 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest105, TestSize.Level1)
2838 {
2839     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2840     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2841         OH_Drawing_CreateFontCollection());
2842     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2843     OH_Drawing_TextBox* textBox = OH_Drawing_TypographyGetRectsForPlaceholders(typography);
2844     OH_Drawing_GetLeftFromTextBox(textBox, 0);
2845     OH_Drawing_GetRightFromTextBox(textBox, 0);
2846     OH_Drawing_GetTopFromTextBox(textBox, 0);
2847     OH_Drawing_GetBottomFromTextBox(textBox, 0);
2848     EXPECT_EQ(OH_Drawing_GetTextDirectionFromTextBox(textBox, 0), 0);
2849     EXPECT_EQ(OH_Drawing_GetSizeOfTextBox(textBox), 0);
2850 
2851     OH_Drawing_PositionAndAffinity* positionAndAffinity =
2852         OH_Drawing_TypographyGetGlyphPositionAtCoordinate(typography, 1, 0);
2853     OH_Drawing_GetPositionFromPositionAndAffinity(positionAndAffinity);
2854     OH_Drawing_GetAffinityFromPositionAndAffinity(positionAndAffinity);
2855 
2856     OH_Drawing_Range* range = OH_Drawing_TypographyGetWordBoundary(typography, 1);
2857     OH_Drawing_GetStartFromRange(range);
2858     OH_Drawing_GetEndFromRange(range);
2859     OH_Drawing_TypographyGetLineHeight(typography, 1);
2860     OH_Drawing_TypographyGetLineWidth(typography, 1);
2861 }
2862 
2863 /*
2864  * @tc.name: OH_Drawing_TypographyTest106
2865  * @tc.desc: test for the textbox.
2866  * @tc.type: FUNC
2867  */
2868 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest106, TestSize.Level1)
2869 {
2870     OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
2871     OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
2872         OH_Drawing_CreateFontCollection());
2873     OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
2874     OH_Drawing_TextBox* textBox = OH_Drawing_TypographyGetRectsForPlaceholders(typography);
2875     EXPECT_EQ(textBox == nullptr, false);
2876     OH_Drawing_DestroyTypographyStyle(typoStyle);
2877     OH_Drawing_DestroyTypographyHandler(handler);
2878     OH_Drawing_DestroyTypography(typography);
2879     OH_Drawing_TypographyDestroyTextBox(textBox);
2880 }
2881 
2882 /*
2883  * @tc.name: OH_Drawing_TypographyTest107
2884  * @tc.desc: test for the textshadow.
2885  * @tc.type: FUNC
2886  */
2887 HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest107, TestSize.Level1)
2888 {
2889     OH_Drawing_TextShadow* shadow = OH_Drawing_CreateTextShadow();
2890     uint32_t color = 0;
2891     OH_Drawing_Point* offset = OH_Drawing_PointCreate(0, 0);
2892     double blurRadius = 0.0;
2893     OH_Drawing_SetTextShadow(shadow, color, offset, blurRadius);
2894     OH_Drawing_DestroyTextShadow(shadow);
2895     OH_Drawing_PointDestroy(offset);
2896     EXPECT_TRUE(shadow != nullptr);
2897 }
2898 }