• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, 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 /**
17  * @addtogroup Drawing
18  * @{
19  *
20  * @brief Provides the text run capability.
21  *
22  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
23  *
24  * @since 18
25  * @version 1.0
26  */
27 
28 /**
29  * @file drawing_text_run.h
30  *
31  * @brief Declares functions related to <b>run</b> in the drawing module.
32  *
33  * @kit ArkGraphics2D
34  * @library libnative_drawing.so
35  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
36  * @since 18
37  * @version 1.0
38  */
39 
40 #ifndef C_INCLUDE_DRAWING_TEXT_RUN_H
41 #define C_INCLUDE_DRAWING_TEXT_RUN_H
42 
43 #include "drawing_text_declaration.h"
44 #include "drawing_types.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 /**
50  * @brief Gets the run glyph indices ,the offset of the index relative to the entire paragraph.
51  *
52  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
53  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
54  * @param start The run of start index.
55  * @param length The run of length, if start and length are set to 0, then get all of the current run.
56  * @return Run of glyph indices array object <b>OH_Drawing_Array</b>.
57  * @since 18
58  */
59 OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, int64_t start, int64_t length);
60 
61 /**
62  * @brief Gets the run glyph indices by index.
63  *
64  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
65  * @param stringIndices the run glyph indices array object <b>OH_Drawing_Array</b>.
66  * @param index The run of glyph index.
67  * @return Run of glyph indices element.
68  * @since 18
69  */
70 uint64_t OH_Drawing_GetRunStringIndicesByIndex(OH_Drawing_Array* stringIndices, size_t index);
71 
72 /**
73  * @brief Releases the memory run glyph indices array.
74  *
75  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
76  * @param stringIndices glyph indices array object <b>OH_Drawing_Array</b>.
77  * @since 18
78  */
79 void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* stringIndices);
80 
81 /**
82  * @brief Gets the range run glyph location and length.
83  *
84  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
85  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
86  * @param location The run of glyph location.
87  * @param length The run of glyph length.
88  * @since 18
89  */
90 void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint64_t* location, uint64_t* length);
91 
92 /**
93  * @brief Gets the run typographic bound.
94  *
95  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
96  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
97  * @param ascent The run of ascent.
98  * @param descent The run of descent.
99  * @param leading The run of leading.
100  * @return run typographic width.
101  * @since 18
102  */
103 float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, float* descent, float* leading);
104 
105 /**
106  * @brief Paints text on the canvas.
107  *
108  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
109  * @param canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
110  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
111  * @param x Indicates the x coordinate.
112  * @param y Indicates the y coordinate.
113  * @since 18
114  */
115 void OH_Drawing_RunPaint(OH_Drawing_Canvas* canvas, OH_Drawing_Run* run, double x, double y);
116 
117 /**
118  * @brief Gets the run image bound.
119  *
120  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
121  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
122  * @return The run image bounds to an <b>OH_Drawing_Rect</b> object.
123  * @since 18
124  */
125 OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run);
126 
127  /**
128  * @brief Releases the memory run image bounds pointer.
129  *
130  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
131  * @param rect Run image bounds to an <b>OH_Drawing_Rect</b> object.
132  * @since 18
133  */
134 void OH_Drawing_DestroyRunImageBounds(OH_Drawing_Rect* rect);
135 
136 /**
137  * @brief Gets the range glyph identifier for each character.
138  *
139  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
140  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
141  * @param start The run of start index.
142  * @param length The run of length, if start and length are set to 0, then get all of the current run.
143  * @return Run of glyph array object <b>OH_Drawing_Array</b.
144  * @since 18
145  */
146 OH_Drawing_Array* OH_Drawing_GetRunGlyphs(OH_Drawing_Run* run, int64_t start, int64_t length);
147 
148 /**
149  * @brief Gets the glyph identifier by index.
150  *
151  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
152  * @param glyphs The run of glyph array object <b>OH_Drawing_Array</b>.
153  * @param index The run of glyph index.
154  * @return Run of glyph element.
155  * @since 18
156  * @version 1.0
157  */
158 uint16_t OH_Drawing_GetRunGlyphsByIndex(OH_Drawing_Array* glyphs, size_t index);
159 
160 /**
161  * @brief Releases the memory run glyph array.
162  *
163  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
164  * @param glyphs The run of glyph array object <b>OH_Drawing_Array</b>.
165  * @since 18
166  */
167 void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs);
168 
169 /**
170  * @brief Gets the range glyph position array.
171  *
172  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
173  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
174  * @param start The run of start index.
175  * @param length The run of length, if start and length are set to 0, then get all of the current run.
176  * @return Run of position array object <b>OH_Drawing_Array</b>.
177  * @since 18
178  */
179 OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, int64_t start, int64_t length);
180 
181 /**
182  * @brief Gets the glyph position by index.
183  *
184  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
185  * @param positions The run of position array object <b>OH_Drawing_Array</b>.
186  * @param index The run of glyph index.
187  * @return Run of glyph position pointer to an <b>OH_Drawing_Point</b> object.
188  * @since 18
189  * @version 1.0
190  */
191 OH_Drawing_Point* OH_Drawing_GetRunPositionsByIndex(OH_Drawing_Array* positions, size_t index);
192 
193 /**
194  * @brief Releases the memory run of position array.
195  *
196  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
197  * @param positions The run of position array object <b>OH_Drawing_Array</b>.
198  * @since 18
199  */
200 void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions);
201 
202 /**
203  * @brief Gets the number of glyph.
204  *
205  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
206  * @param run Indicates the pointer to an <b>OH_Drawing_Run</b> object.
207  * @return The number of glyph.
208  * @since 18
209  */
210 uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run);
211 #ifdef __cplusplus
212 }
213 #endif
214 /** @} */
215 #endif // C_INCLUDE_DRAWING_TEXT_RUN_H
216