• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef C_INCLUDE_DRAWING_TEXT_BLOB_H
17 #define C_INCLUDE_DRAWING_TEXT_BLOB_H
18 
19 /**
20  * @addtogroup Drawing
21  * @{
22  *
23  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
26  *
27  * @since 11
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_text_blob.h
33  *
34  * @brief Declares functions related to the <b>textBlob</b> object in the drawing module.
35  *
36  * @since 11
37  * @version 1.0
38  */
39 
40 #include "drawing_types.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Creates an <b>OH_Drawing_TextBlobBuilder</b> object.
48  *
49  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
50  * @return Returns the pointer to the <b>OH_Drawing_TextBlobBuilder</b> object created.
51  * @since 11
52  * @version 1.0
53  */
54 OH_Drawing_TextBlobBuilder* OH_Drawing_TextBlobBuilderCreate(void);
55 
56 /**
57  * @brief Defines a run, supplies storage for glyphs and positions.
58  *
59  * @since 11
60  * @version 1.0
61  */
62 typedef struct {
63     /** storage for glyph indexes in run */
64     uint16_t* glyphs;
65     /** storage for glyph positions in run */
66     float* pos;
67     /** storage for text UTF-8 code units in run */
68     char* utf8text;
69     /** storage for glyph clusters (index of UTF-8 code unit) */
70     uint32_t* clusters;
71 } OH_Drawing_RunBuffer;
72 
73 /**
74  * @brief Alloc run with storage for glyphs and positions. The returned pointer does not need to be managed
75  * by the caller and is forbidden to be used after OH_Drawing_TextBlobBuilderMake is called.
76  *
77  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
78  * @param OH_Drawing_TextBlobBuilder Indicates the pointer to an <b>OH_Drawing_TextBlobBuilder</b> object.
79  * @param OH_Drawing_Font Indicates the pointer to an <b>OH_Drawing_Font</b> object.
80  * @param count Indicates the number of glyphs.
81  * @param OH_Drawing_Rect Indicates the optional run bounding box.
82  * @since 11
83  * @version 1.0
84  */
85 const OH_Drawing_RunBuffer* OH_Drawing_TextBlobBuilderAllocRunPos(OH_Drawing_TextBlobBuilder*, const OH_Drawing_Font*,
86     int32_t count, const OH_Drawing_Rect*);
87 
88 /**
89  * @brief Make an <b>OH_Drawing_TextBlob</b> from <b>OH_Drawing_TextBlobBuilder</b>.
90  *
91  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
92  * @param OH_Drawing_TextBlobBuilder Indicates the pointer to an <b>OH_Drawing_TextBlobBuilder</b> object.
93  * @return Returns the pointer to the <b>OH_Drawing_TextBlob</b> object.
94  * @since 11
95  * @version 1.0
96  */
97 OH_Drawing_TextBlob* OH_Drawing_TextBlobBuilderMake(OH_Drawing_TextBlobBuilder*);
98 
99 /**
100  * @brief Destroys an <b>OH_Drawing_TextBlob</b> object and reclaims the memory occupied by the object.
101  *
102  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
103  * @param OH_Drawing_TextBlob Indicates the pointer to an <b>OH_Drawing_TextBlob</b> object.
104  * @since 11
105  * @version 1.0
106  */
107 void OH_Drawing_TextBlobDestroy(OH_Drawing_TextBlob*);
108 
109 /**
110  * @brief Destroys an <b>OH_Drawing_TextBlobBuilder</b> object and reclaims the memory occupied by the object.
111  *
112  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
113  * @param OH_Drawing_TextBlobBuilder Indicates the pointer to an <b>OH_Drawing_TextBlobBuilder</b> object.
114  * @since 11
115  * @version 1.0
116  */
117 void OH_Drawing_TextBlobBuilderDestroy(OH_Drawing_TextBlobBuilder*);
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 /** @} */
123 #endif
124