1# Drawing 2 3 4The **Drawing** module provides functions for 2D graphics rendering, text drawing, and image display. 5 6 7It provides the 2D drawing capability. 8 9 10@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 11 12 13**Since** 14 15 168 17 18 19## Summary 20 21 22### Files 23 24| Name | Description | 25| ------------------------------------------------------------ | ------------------------------------------------------------ | 26| [drawing_bitmap.h](drawing__bitmap_8h.md) | Declares functions related to the **bitmap** object in the drawing module.<br>File to include: <native_drawing/drawing_bitmap.h> <br>Library: libnative_drawing.so | 27| [drawing_brush.h](drawing__brush_8h.md) | Declares functions related to the **brush** object in the drawing module.<br>File to include: <native_drawing/drawing_brush.h> <br>Library: libnative_drawing.so | 28| [drawing_canvas.h](drawing__canvas_8h.md) | Declares functions related to the **canvas** object in the drawing module.<br>File to include: <native_drawing/drawing_canvas.h> <br>Library: libnative_drawing.so | 29| [drawing_color.h](drawing__color_8h.md) | Declares functions related to the **color** object in the drawing module.<br>File to include: <native_drawing/drawing_color.h> <br>Library: libnative_drawing.so | 30| [drawing_font_collection.h](drawing__font__collection_8h.md) | Declares functions related to **FontCollection** in the drawing module.<br>File to include: <native_drawing/drawing_font_collection.h><br>Library: libnative_drawing.so | 31| [drawing_path.h](drawing__path_8h.md) | Declares functions related to the **path** object in the drawing module.<br>File to include: <native_drawing/drawing_path.h><br>Library: libnative_drawing.so | 32| [drawing_pen.h](drawing__pen_8h.md) | Declares functions related to the **pen** object in the drawing module.<br>File to include: <native_drawing/drawing_pen.h><br>Library: libnative_drawing.so | 33| [drawing_text_declaration.h](drawing__text__declaration_8h.md) | Declares the struct related to text in 2D drawing.<br>File to include: <native_drawing/drawing_text_declaration.h><br>Library: libnative_drawing.so | 34| [drawing_text_typography.h](drawing__text__typography_8h.md) | Declares functions related to **typography** in the drawing module.<br>File to include: <native_drawing/drawing_text_typography.h><br>Library: libnative_drawing.so | 35| [drawing_types.h](drawing__types_8h.md) | Declares the data types for drawing 2D graphics, including the canvas, brush, pen, bitmap, and path.<br>File to include: <native_drawing/drawing_types.h><br>Library: libnative_drawing.so| 36 37 38### Structs 39 40| Name | Description | 41| ------------------------------------------------------------ | -------------------------------------------------------- | 42| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Defines the pixel format of a bitmap, including the color type and alpha type.| 43 44 45### Types 46 47| Name | Description | 48| ----------------------------------------------------------- | ------------------------------------------------------------ | 49| [OH_Drawing_FontCollection](#oh_drawing_fontcollection) | Defines an **OH_Drawing_FontCollection**, which is used to load fonts. | 50| [OH_Drawing_Typography](#oh_drawing_typography) | Defines an **OH_Drawing_Typography**, which is used to manage the typography layout and display. | 51| [OH_Drawing_TextStyle](#oh_drawing_textstyle) | Defines an **OH_Drawing_TextStyle**, which is used to manage text colors and decorations. | 52| [OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) | Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction. | 53| [OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) | Defines an **OH_Drawing_TypographyCreate**, which is used to create an **OH_Drawing_Typography** object. | 54| [OH_Drawing_Canvas](#oh_drawing_canvas) | Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen.| 55| [OH_Drawing_Pen](#oh_drawing_pen) | Defines a pen, which is used to describe the style and color to outline a shape.| 56| [OH_Drawing_Brush](#oh_drawing_brush) | Defines a brush, which is used to describe the style and color to fill in a shape.| 57| [OH_Drawing_Path](#oh_drawing_path) | Defines a path, which is used to customize various shapes. | 58| [OH_Drawing_Bitmap](#oh_drawing_bitmap) | Defines a bitmap, which is a memory area that contains the pixel data of a shape.| 59 60 61### Enums 62 63| Name | Description | 64| ------------------------------------------------------------ | ------------------------------------------------------------ | 65| [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle) { LINE_FLAT_CAP, LINE_SQUARE_CAP, LINE_ROUND_CAP } | Enumerates the line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen.| 66| [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle) { LINE_MITER_JOIN, LINE_ROUND_JOIN, LINE_BEVEL_JOIN } | Enumerates the line join styles of a pen. The line join style defines the shape of the joints of a polyline segment drawn by the pen.| 67| [OH_Drawing_TextDirection](#oh_drawing_textdirection) { TEXT_DIRECTION_RTL, TEXT_DIRECTION_LTR } | Enumerates the text directions. | 68| [OH_Drawing_TextAlign](#oh_drawing_textalign) { TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER, TEXT_ALIGN_JUSTIFY, TEXT_ALIGN_START, TEXT_ALIGN_END } | Enumerates the text alignment modes. | 69| [OH_Drawing_FontWeight](#oh_drawing_fontweight) { FONT_WEIGHT_100, FONT_WEIGHT_200, FONT_WEIGHT_300, FONT_WEIGHT_400, FONT_WEIGHT_500, FONT_WEIGHT_600, FONT_WEIGHT_700, FONT_WEIGHT_800, FONT_WEIGHT_900 } | Enumerates the font weights. | 70| [OH_Drawing_TextBaseline](#oh_drawing_textbaseline) { TEXT_BASELINE_ALPHABETIC, TEXT_BASELINE_IDEOGRAPHIC } | Enumerates the text baselines. | 71| [OH_Drawing_TextDecoration](#oh_drawing_textdecoration) { TEXT_DECORATION_NONE = 0x0, TEXT_DECORATION_UNDERLINE = 0x1, TEXT_DECORATION_OVERLINE = 0x2, TEXT_DECORATION_LINE_THROUGH = 0x4 } | Enumerates the text decorations. | 72| [OH_Drawing_FontStyle](#oh_drawing_fontstyle) { FONT_STYLE_NORMAL, FONT_STYLE_ITALIC } | Enumerates the font styles. | 73| [OH_Drawing_ColorFormat](#oh_drawing_colorformat) { COLOR_FORMAT_UNKNOWN, COLOR_FORMAT_ALPHA_8, COLOR_FORMAT_RGB_565, COLOR_FORMAT_ARGB_4444, COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888 } | Enumerates the storage formats of bitmap pixels. | 74| [OH_Drawing_AlphaFormat](#oh_drawing_alphaformat) { ALPHA_FORMAT_UNKNOWN, ALPHA_FORMAT_OPAQUE, ALPHA_FORMAT_PREMUL, ALPHA_FORMAT_UNPREMUL } | Enumerates the alpha formats of bitmap pixels. | 75 76 77### Functions 78 79| Name | Description | 80| ------------------------------------------------------------ | ------------------------------------------------------------ | 81| [OH_Drawing_BitmapCreate](#oh_drawing_bitmapcreate) (void) | Creates an **OH_Drawing_Bitmap** object. | 82| [OH_Drawing_BitmapDestroy](#oh_drawing_bitmapdestroy) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Destroys an **OH_Drawing_Bitmap** object and reclaims the memory occupied by the object. | 83| [OH_Drawing_BitmapBuild](#oh_drawing_bitmapbuild) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*, const uint32_t width, const uint32_t height, const [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) \*) | Initializes the width and height of an **OH_Drawing_Bitmap** object and sets its pixel format. | 84| [OH_Drawing_BitmapGetWidth](#oh_drawing_bitmapgetwidth) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Obtains the width of a bitmap. | 85| [OH_Drawing_BitmapGetHeight](#oh_drawing_bitmapgetheight) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Obtains the height of a bitmap. | 86| [OH_Drawing_BitmapGetPixels](#oh_drawing_bitmapgetpixels) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap.| 87| [OH_Drawing_BrushCreate](#oh_drawing_brushcreate) (void) | Creates an **OH_Drawing_Brush** object. | 88| [OH_Drawing_BrushDestroy](#oh_drawing_brushdestroy) ([OH_Drawing_Brush](#oh_drawing_brush) \*) | Destroys an **OH_Drawing_Brush** object and reclaims the memory occupied by the object. | 89| [OH_Drawing_BrushIsAntiAlias](#oh_drawing_brushisantialias) (const [OH_Drawing_Brush](#oh_drawing_brush) \*) | Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency.| 90| [OH_Drawing_BrushSetAntiAlias](#oh_drawing_brushsetantialias) ([OH_Drawing_Brush](#oh_drawing_brush) \*, bool) | Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency.| 91| [OH_Drawing_BrushGetColor](#oh_drawing_brushgetcolor) (const [OH_Drawing_Brush](#oh_drawing_brush) \*) | Obtains the color of a brush. The color is used by the brush to fill in a shape.| 92| [OH_Drawing_BrushSetColor](#oh_drawing_brushsetcolor) ([OH_Drawing_Brush](#oh_drawing_brush) \*, uint32_t color) | Sets the color for a brush. The color will be used by the brush to fill in a shape.| 93| [OH_Drawing_CanvasCreate](#oh_drawing_canvascreate) (void) | Creates an **OH_Drawing_Canvas** object. | 94| [OH_Drawing_CanvasDestroy](#oh_drawing_canvasdestroy) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Destroys an **OH_Drawing_Canvas** object and reclaims the memory occupied by the object. | 95| [OH_Drawing_CanvasBind](#oh_drawing_canvasbind) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, [OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap. (This process is called CPU rendering.)| 96| [OH_Drawing_CanvasAttachPen](#oh_drawing_canvasattachpen) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape.| 97| [OH_Drawing_CanvasDetachPen](#oh_drawing_canvasdetachpen) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. | 98| [OH_Drawing_CanvasAttachBrush](#oh_drawing_canvasattachbrush) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, const [OH_Drawing_Brush](#oh_drawing_brush) \*) | Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape.| 99| [OH_Drawing_CanvasDetachBrush](#oh_drawing_canvasdetachbrush) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. | 100| [OH_Drawing_CanvasSave](#oh_drawing_canvassave) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Saves the current canvas status (canvas matrix) to the top of the stack. | 101| [OH_Drawing_CanvasRestore](#oh_drawing_canvasrestore) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Restores the canvas status (canvas matrix) saved on the top of the stack. | 102| [OH_Drawing_CanvasDrawLine](#oh_drawing_canvasdrawline) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, float x1, float y1, float x2, float y2) | Draws a line segment. | 103| [OH_Drawing_CanvasDrawPath](#oh_drawing_canvasdrawpath) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, const [OH_Drawing_Path](#oh_drawing_path) \*) | Draws a path. | 104| [OH_Drawing_CanvasClear](#oh_drawing_canvasclear) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, uint32_t color) | Clears a canvas by using a specified color. | 105| [OH_Drawing_ColorSetArgb](#oh_drawing_colorsetargb) (uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue) | Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color.| 106| [OH_Drawing_CreateFontCollection](#oh_drawing_createfontcollection) (void) | Creates an **OH_Drawing_FontCollection** object. | 107| [OH_Drawing_DestroyFontCollection](#oh_drawing_destroyfontcollection) ([OH_Drawing_FontCollection](#oh_drawing_fontcollection) \*) | Destroys an **OH_Drawing_FontCollection** object and reclaims the memory occupied by the object. | 108| [OH_Drawing_PathCreate](#oh_drawing_pathcreate) (void) | Creates an **OH_Drawing_Path** object. | 109| [OH_Drawing_PathDestroy](#oh_drawing_pathdestroy) ([OH_Drawing_Path](#oh_drawing_path) \*) | Destroys an **OH_Drawing_Path** object and reclaims the memory occupied by the object. | 110| [OH_Drawing_PathMoveTo](#oh_drawing_pathmoveto) ([OH_Drawing_Path](#oh_drawing_path) \*, float x, float y) | Sets the start point of a path. | 111| [OH_Drawing_PathLineTo](#oh_drawing_pathlineto) ([OH_Drawing_Path](#oh_drawing_path) \*, float x, float y) | Draws a line segment from the last point of a path to the target point. | 112| [OH_Drawing_PathArcTo](#oh_drawing_patharcto) ([OH_Drawing_Path](#oh_drawing_path) \*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg) | Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added.| 113| [OH_Drawing_PathQuadTo](#oh_drawing_pathquadto) ([OH_Drawing_Path](#oh_drawing_path) \*, float ctrlX, float ctrlY, float endX, float endY) | Draws a quadratic Bezier curve from the last point of a path to the target point. | 114| [OH_Drawing_PathCubicTo](#oh_drawing_pathcubicto) ([OH_Drawing_Path](#oh_drawing_path) \*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) | Draws a cubic Bezier curve from the last point of a path to the target point. | 115| [OH_Drawing_PathClose](#oh_drawing_pathclose) ([OH_Drawing_Path](#oh_drawing_path) \*) | Closes a path. A line segment from the start point to the last point of the path is added. | 116| [OH_Drawing_PathReset](#oh_drawing_pathreset) ([OH_Drawing_Path](#oh_drawing_path) \*) | Resets path data. | 117| [OH_Drawing_PenCreate](#oh_drawing_pencreate) (void) | Creates an **OH_Drawing_Pen** object. | 118| [OH_Drawing_PenDestroy](#oh_drawing_pendestroy) ([OH_Drawing_Pen](#oh_drawing_pen) \*) | Destroys an **OH_Drawing_Pen** object and reclaims the memory occupied by the object. | 119| [OH_Drawing_PenIsAntiAlias](#oh_drawing_penisantialias) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency.| 120| [OH_Drawing_PenSetAntiAlias](#oh_drawing_pensetantialias) ([OH_Drawing_Pen](#oh_drawing_pen) \*, bool) | Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency.| 121| [OH_Drawing_PenGetColor](#oh_drawing_pengetcolor) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the color of a pen. The color is used by the pen to outline a shape.| 122| [OH_Drawing_PenSetColor](#oh_drawing_pensetcolor) ([OH_Drawing_Pen](#oh_drawing_pen) \*, uint32_t color) | Sets the color for a pen. The color is used by the pen to outline a shape.| 123| [OH_Drawing_PenGetWidth](#oh_drawing_pengetwidth) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. | 124| [OH_Drawing_PenSetWidth](#oh_drawing_pensetwidth) ([OH_Drawing_Pen](#oh_drawing_pen) \*, float width) | Sets the thickness for a pen. This thickness determines the width of the outline of a shape. | 125| [OH_Drawing_PenGetMiterLimit](#oh_drawing_pengetmiterlimit) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.| 126| [OH_Drawing_PenSetMiterLimit](#oh_drawing_pensetmiterlimit) ([OH_Drawing_Pen](#oh_drawing_pen) \*, float miter) | Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.| 127| [OH_Drawing_PenGetCap](#oh_drawing_pengetcap) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the line cap style of a pen. | 128| [OH_Drawing_PenSetCap](#oh_drawing_pensetcap) ([OH_Drawing_Pen](#oh_drawing_pen) \*, [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle)) | Sets the line cap style for a pen. | 129| [OH_Drawing_PenGetJoin](#oh_drawing_pengetjoin) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the line join style of a pen. | 130| [OH_Drawing_PenSetJoin](#oh_drawing_pensetjoin) ([OH_Drawing_Pen](#oh_drawing_pen) \*, [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle)) | Sets the line join style for a pen. | 131| [OH_Drawing_CreateTypographyStyle](#oh_drawing_createtypographystyle) (void) | Creates an **OH_Drawing_TypographyStyle** object. | 132| [OH_Drawing_DestroyTypographyStyle](#oh_drawing_destroytypographystyle) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*) | Destroys an **OH_Drawing_TypographyStyle** object and reclaims the memory occupied by the object. | 133| [OH_Drawing_SetTypographyTextDirection](#oh_drawing_settypographytextdirection) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, int) | Sets the text direction. | 134| [OH_Drawing_SetTypographyTextAlign](#oh_drawing_settypographytextalign) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, int) | Sets the text alignment mode. | 135| [OH_Drawing_SetTypographyTextMaxLines](#oh_drawing_settypographytextmaxlines) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, int) | Sets the maximum number of lines in the text. | 136| [OH_Drawing_CreateTextStyle](#oh_drawing_createtextstyle) (void) | Creates an **OH_Drawing_TextStyle** object. | 137| [OH_Drawing_DestroyTextStyle](#oh_drawing_destroytextstyle) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*) | Destroys an **OH_Drawing_TextStyle** object and reclaims the memory occupied by the object. | 138| [OH_Drawing_SetTextStyleColor](#oh_drawing_settextstylecolor) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, uint32_t) | Sets the text color. | 139| [OH_Drawing_SetTextStyleFontSize](#oh_drawing_settextstylefontsize) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, double) | Sets the font size. | 140| [OH_Drawing_SetTextStyleFontWeight](#oh_drawing_settextstylefontweight) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the font weight. | 141| [OH_Drawing_SetTextStyleBaseLine](#oh_drawing_settextstylebaseline) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the text baseline. | 142| [OH_Drawing_SetTextStyleDecoration](#oh_drawing_settextstyledecoration) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the text decoration. | 143| [OH_Drawing_SetTextStyleDecorationColor](#oh_drawing_settextstyledecorationcolor) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, uint32_t) | Sets the color for the text decoration. | 144| [OH_Drawing_SetTextStyleFontHeight](#oh_drawing_settextstylefontheight) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, double) | Sets the font height. | 145| [OH_Drawing_SetTextStyleFontFamilies](#oh_drawing_settextstylefontfamilies) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int, const char \*fontFamilies[]) | Sets the font families. | 146| [OH_Drawing_SetTextStyleFontStyle](#oh_drawing_settextstylefontstyle) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the font style. | 147| [OH_Drawing_SetTextStyleLocale](#oh_drawing_settextstylelocale) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, const char \*) | Sets the locale. | 148| [OH_Drawing_CreateTypographyHandler](#oh_drawing_createtypographyhandler) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, [OH_Drawing_FontCollection](#oh_drawing_fontcollection) \*) | Creates an **OH_Drawing_TypographyCreate** object. | 149| [OH_Drawing_DestroyTypographyHandler](#oh_drawing_destroytypographyhandler) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*) | Destroys an **OH_Drawing_TypographyCreate** object and reclaims the memory occupied by the object. | 150| [OH_Drawing_TypographyHandlerPushTextStyle](#oh_drawing_typographyhandlerpushtextstyle) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*, [OH_Drawing_TextStyle](#oh_drawing_textstyle) \*) | Sets the text style. | 151| [OH_Drawing_TypographyHandlerAddText](#oh_drawing_typographyhandleraddtext) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*, const char \*) | Sets the text content. | 152| [OH_Drawing_TypographyHandlerPopTextStyle](#oh_drawing_typographyhandlerpoptextstyle) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*) | Removes the topmost style in the stack, leaving the remaining styles in effect. | 153| [OH_Drawing_CreateTypography](#oh_drawing_createtypography) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*) | Creates an **OH_Drawing_Typography** object. | 154| [OH_Drawing_DestroyTypography](#oh_drawing_destroytypography) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Destroys an **OH_Drawing_Typography** object and reclaims the memory occupied by the object. | 155| [OH_Drawing_TypographyLayout](#oh_drawing_typographylayout) ([OH_Drawing_Typography](#oh_drawing_typography) \*, double) | Lays out the typography. | 156| [OH_Drawing_TypographyPaint](#oh_drawing_typographypaint) ([OH_Drawing_Typography](#oh_drawing_typography) \*, [OH_Drawing_Canvas](#oh_drawing_canvas) \*, double, double) | Paints text on the canvas. | 157| [OH_Drawing_TypographyGetMaxWidth](#oh_drawing_typographygetmaxwidth) ([OH_Drawing_Typography](#oh_drawing_typography) *) | Obtains the maximum width. | 158| [OH_Drawing_TypographyGetHeight](#oh_drawing_typographygetheight) ([OH_Drawing_Typography](#oh_drawing_typography) *) | Obtains the height. | 159| [OH_Drawing_TypographyGetLongestLine](#oh_drawing_typographygetlongestline) ([OH_Drawing_Typography](#oh_drawing_typography) *) | Obtains the longest line. | 160| [OH_Drawing_TypographyGetMinIntrinsicWidth](#oh_drawing_typographygetminintrinsicwidth) ([OH_Drawing_Typography](#oh_drawing_typography) *) | Obtains the minimum intrinsic width. | 161| [OH_Drawing_TypographyGetMaxIntrinsicWidth](#oh_drawing_typographygetmaxintrinsicwidth) ([OH_Drawing_Typography](#oh_drawing_typography) *) | Obtains the maximum intrinsic width. | 162| [OH_Drawing_TypographyGetAlphabeticBaseline](#oh_drawing_typographygetalphabeticbaseline)([OH_Drawing_Typography](#oh_drawing_typography) *) | Obtains the alphabetic baseline. | 163| [OH_Drawing_TypographyGetIdeographicBaseline](#oh_drawing_typographygetideographicbaseline) ([OH_Drawing_Typography](#oh_drawing_typography) *) | Obtains the ideographic baseline. | 164 165 166## Type Description 167 168 169### OH_Drawing_Bitmap 170 171 172``` 173typedef struct OH_Drawing_Bitmap OH_Drawing_Bitmap 174``` 175 176**Description** 177 178Defines a bitmap, which is a memory area that contains the pixel data of a shape. 179 180**Since** 181 1828 183 184 185### OH_Drawing_Brush 186 187 188``` 189typedef struct OH_Drawing_Brush OH_Drawing_Brush 190``` 191 192**Description** 193 194Defines a brush, which is used to describe the style and color to fill in a shape. 195 196**Since** 197 1988 199 200 201### OH_Drawing_Canvas 202 203 204``` 205typedef struct OH_Drawing_Canvas OH_Drawing_Canvas 206``` 207 208**Description** 209 210Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen. 211 212**Since** 213 2148 215 216 217### OH_Drawing_FontCollection 218 219 220``` 221typedef struct OH_Drawing_FontCollection OH_Drawing_FontCollection 222``` 223 224**Description** 225 226Defines an **OH_Drawing_FontCollection**, which is used to load fonts. 227 228**Since** 229 2308 231 232 233### OH_Drawing_Path 234 235 236``` 237typedef struct OH_Drawing_Path OH_Drawing_Path 238``` 239 240**Description** 241 242Defines a path, which is used to customize various shapes. 243 244**Since** 245 2468 247 248 249### OH_Drawing_Pen 250 251 252``` 253typedef struct OH_Drawing_Pen OH_Drawing_Pen 254``` 255 256**Description** 257 258Defines a pen, which is used to describe the style and color to outline a shape. 259 260**Since** 261 2628 263 264 265### OH_Drawing_TextStyle 266 267 268``` 269typedef struct OH_Drawing_TextStyle OH_Drawing_TextStyle 270``` 271 272**Description** 273 274Defines an **OH_Drawing_TextStyle**, which is used to manage text colors and decorations. 275 276**Since** 277 2788 279 280 281### OH_Drawing_Typography 282 283 284``` 285typedef struct OH_Drawing_Typography OH_Drawing_Typography 286``` 287 288**Description** 289 290Defines an **OH_Drawing_Typography**, which is used to manage the typography layout and display. 291 292**Since** 293 2948 295 296 297### OH_Drawing_TypographyCreate 298 299 300``` 301typedef struct OH_Drawing_TypographyCreate OH_Drawing_TypographyCreate 302``` 303 304**Description** 305 306Defines an **OH_Drawing_TypographyCreate**, which is used to create an **OH_Drawing_Typography** object. 307 308**Since** 309 3108 311 312 313### OH_Drawing_TypographyStyle 314 315 316``` 317typedef struct OH_Drawing_TypographyStyle OH_Drawing_TypographyStyle 318``` 319 320**Description** 321 322Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction. 323 324**Since** 325 3268 327 328 329## Enum Description 330 331 332### OH_Drawing_AlphaFormat 333 334 335``` 336enum OH_Drawing_AlphaFormat 337``` 338 339**Description** 340 341Enumerates the alpha formats of bitmap pixels. 342 343| Value | Description | 344| --------------------- | ---------------------------------------- | 345| ALPHA_FORMAT_UNKNOWN | Unknown format. | 346| ALPHA_FORMAT_OPAQUE | The bitmap does not have the alpha component. | 347| ALPHA_FORMAT_PREMUL | The color component of each pixel is premultiplied by the alpha component. | 348| ALPHA_FORMAT_UNPREMUL | The color component of each pixel is not premultiplied by the alpha component.| 349 350**Since** 351 3528 353 354 355### OH_Drawing_ColorFormat 356 357 358``` 359enum OH_Drawing_ColorFormat 360``` 361 362**Description** 363 364Enumerates the storage formats of bitmap pixels. 365 366| Value | Description | 367| ---------------------- | ------------------------------------------------------------ | 368| COLOR_FORMAT_UNKNOWN | Unknown format. | 369| COLOR_FORMAT_ALPHA_8 | Each pixel is represented by 8 bits, which together indicate alpha. | 370| COLOR_FORMAT_RGB_565 | Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, the first 5 bits indicate red, the subsequent 6 bits indicate green, and the last 5 bits indicate blue.| 371| COLOR_FORMAT_ARGB_4444 | Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, every 4 bits indicate alpha, red, green, and blue, respectively.| 372| COLOR_FORMAT_RGBA_8888 | Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate alpha, red, green, and blue, respectively.| 373| COLOR_FORMAT_BGRA_8888 | Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate blue, green, red, and alpha, respectively.| 374 375**Since** 376 3778 378 379 380### OH_Drawing_FontStyle 381 382 383``` 384enum OH_Drawing_FontStyle 385``` 386 387**Description** 388 389Enumerates the font styles. 390 391| Value | Description | 392| ----------------- | ------ | 393| FONT_STYLE_NORMAL | Normal style.| 394| FONT_STYLE_ITALIC | Italic. | 395 396**Since** 397 3988 399 400 401### OH_Drawing_FontWeight 402 403 404``` 405enum OH_Drawing_FontWeight 406``` 407 408**Description** 409 410Enumerates the font weights. 411 412| Value | Description | 413| --------------- | -------------------- | 414| FONT_WEIGHT_100 | Thin. | 415| FONT_WEIGHT_200 | Extra-light. | 416| FONT_WEIGHT_300 | Light. | 417| FONT_WEIGHT_400 | .Normal/Regular.| 418| FONT_WEIGHT_500 | Medium. | 419| FONT_WEIGHT_600 | Semi-bold. | 420| FONT_WEIGHT_700 | Bold. | 421| FONT_WEIGHT_800 | Extra-bold. | 422| FONT_WEIGHT_900 | Black. | 423 424**Since** 425 4268 427 428 429### OH_Drawing_PenLineCapStyle 430 431 432``` 433enum OH_Drawing_PenLineCapStyle 434``` 435 436**Description** 437 438Enumerates the line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen. 439 440| Value | Description | 441| --------------- | ------------------------------------------------------------ | 442| LINE_FLAT_CAP | There is no cap style. Both ends of the line segment are cut off square. | 443| LINE_SQUARE_CAP | Square cap style. Both ends have a square, the height of which is half of the width of the line segment, with the same width.| 444| LINE_ROUND_CAP | Round cap style. Both ends have a semicircle centered, the diameter of which is the same as the width of the line segment.| 445 446**Since** 447 4488 449 450 451### OH_Drawing_PenLineJoinStyle 452 453 454``` 455enum OH_Drawing_PenLineJoinStyle 456``` 457 458**Description** 459 460Enumerates the line join styles of a pen. The line join style defines the shape of the joints of a polyline segment drawn by the pen. 461 462| Value | Description | 463| --------------- | ------------------------------------------------------------ | 464| LINE_MITER_JOIN | Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate. In this case, you need to use the miter limit to limit the miter length.| 465| LINE_ROUND_JOIN | Round corner. | 466| LINE_BEVEL_JOIN | Beveled corner. | 467 468**Since** 469 4708 471 472 473### OH_Drawing_TextAlign 474 475 476``` 477enum OH_Drawing_TextAlign 478``` 479 480**Description** 481 482Enumerates the text alignment modes. 483 484| Value | Description | 485| ------------------ | ------------------------------------------------------------ | 486| TEXT_ALIGN_LEFT | Left-aligned. | 487| TEXT_ALIGN_RIGHT | Right-aligned. | 488| TEXT_ALIGN_CENTER | Center-aligned. | 489| TEXT_ALIGN_JUSTIFY | Justified, which means that each line (except the last line) is stretched so that every line has equal width, and the left and right margins are straight.| 490| TEXT_ALIGN_START | **TEXT_ALIGN_START** achieves the same effect as **TEXT_ALIGN_LEFT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_LTR**; it achieves the same effect as **TEXT_ALIGN_RIGHT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_RTL**.| 491| TEXT_ALIGN_END | **TEXT_ALIGN_END** achieves the same effect as **TEXT_ALIGN_RIGHT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_LTR**; it achieves the same effect as **TEXT_ALIGN_LEFT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_RTL**.| 492 493**Since** 494 4958 496 497 498### OH_Drawing_TextBaseline 499 500 501``` 502enum OH_Drawing_TextBaseline 503``` 504 505**Description** 506 507Enumerates the text baselines. 508 509| Value | Description | 510| ------------------------- | ---------------------------------- | 511| TEXT_BASELINE_ALPHABETIC | Alphabetic, where the letters in alphabets like English sit on.| 512| TEXT_BASELINE_IDEOGRAPHIC | Ideographic. The baseline is at the bottom of the text area. | 513 514**Since** 515 5168 517 518 519### OH_Drawing_TextDecoration 520 521 522``` 523enum OH_Drawing_TextDecoration 524``` 525 526**Description** 527 528Enumerates the text decorations. 529 530| Value | Description | 531| ---------------------------- | ------ | 532| TEXT_DECORATION_NONE | No decoration.| 533| TEXT_DECORATION_UNDERLINE | An underline is used for decoration.| 534| TEXT_DECORATION_OVERLINE | An overline is used for decoration.| 535| TEXT_DECORATION_LINE_THROUGH | A strikethrough is used for decoration.| 536 537**Since** 538 5398 540 541 542### OH_Drawing_TextDirection 543 544 545``` 546enum OH_Drawing_TextDirection 547``` 548 549**Description** 550 551Enumerates the text directions. 552 553| Value | Description | 554| ------------------ | -------------- | 555| TEXT_DIRECTION_RTL | Right to left (RTL).| 556| TEXT_DIRECTION_LTR | Left to right (LTR).| 557 558**Since** 559 5608 561 562 563## Function Description 564 565 566### OH_Drawing_BitmapBuild() 567 568 569``` 570void OH_Drawing_BitmapBuild (OH_Drawing_Bitmap * , const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat * ) 571``` 572 573**Description** 574 575Initializes the width and height of an **OH_Drawing_Bitmap** object and sets its pixel format. 576 577@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 578 579**Parameters** 580 581| Name | Description | 582| ------------------------------------------------------------ | ------------------------------------------------------------ | 583| OH_Drawing_Bitmap | Pointer to an **OH_Drawing_Bitmap** object. | 584| width | Width of the bitmap to be initialized. | 585| height | Height of the bitmap to be initialized. | 586| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Pixel format of the bitmap to be initialized, including the pixel color type and alpha type.| 587 588**Since** 589 5908 591 592 593### OH_Drawing_BitmapCreate() 594 595 596``` 597OH_Drawing_Bitmap* OH_Drawing_BitmapCreate (void ) 598``` 599 600**Description** 601 602Creates an **OH_Drawing_Bitmap** object. 603 604@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 605 606**Returns** 607 608Returns the pointer to the **OH_Drawing_Bitmap** object created. 609 610**Since** 611 6128 613 614 615### OH_Drawing_BitmapDestroy() 616 617 618``` 619void OH_Drawing_BitmapDestroy (OH_Drawing_Bitmap * ) 620``` 621 622**Description** 623 624Destroys an **OH_Drawing_Bitmap** object and reclaims the memory occupied by the object. 625 626@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 627 628**Parameters** 629 630| Name | Description | 631| ----------------- | ---------------------------- | 632| OH_Drawing_Bitmap | Pointer to an **OH_Drawing_Bitmap** object.| 633 634**Since** 635 6368 637 638 639### OH_Drawing_BitmapGetHeight() 640 641 642``` 643uint32_t OH_Drawing_BitmapGetHeight (OH_Drawing_Bitmap * ) 644``` 645 646**Description** 647 648Obtains the height of a bitmap. 649 650@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 651 652**Parameters** 653 654| Name | Description | 655| ----------------- | ---------------------------- | 656| OH_Drawing_Bitmap | Pointer to an **OH_Drawing_Bitmap** object.| 657 658**Returns** 659 660Returns the height. 661 662**Since** 663 6648 665 666 667### OH_Drawing_BitmapGetPixels() 668 669 670``` 671void* OH_Drawing_BitmapGetPixels (OH_Drawing_Bitmap * ) 672``` 673 674**Description** 675 676Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. 677 678@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 679 680**Parameters** 681 682| Name | Description | 683| ----------------- | ---------------------------- | 684| OH_Drawing_Bitmap | Pointer to an **OH_Drawing_Bitmap** object.| 685 686**Returns** 687 688Returns the pixel address. 689 690**Since** 691 6928 693 694 695### OH_Drawing_BitmapGetWidth() 696 697 698``` 699uint32_t OH_Drawing_BitmapGetWidth (OH_Drawing_Bitmap * ) 700``` 701 702**Description** 703 704Obtains the width of a bitmap. 705 706@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 707 708**Parameters** 709 710| Name | Description | 711| ----------------- | ---------------------------- | 712| OH_Drawing_Bitmap | Pointer to an **OH_Drawing_Bitmap** object.| 713 714**Returns** 715 716Returns the width. 717 718**Since** 719 7208 721 722 723### OH_Drawing_BrushCreate() 724 725 726``` 727OH_Drawing_Brush* OH_Drawing_BrushCreate (void ) 728``` 729 730**Description** 731 732Creates an **OH_Drawing_Brush** object. 733 734@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 735 736**Returns** 737 738Returns the pointer to the **OH_Drawing_Brush** object created. 739 740**Since** 741 7428 743 744 745### OH_Drawing_BrushDestroy() 746 747 748``` 749void OH_Drawing_BrushDestroy (OH_Drawing_Brush * ) 750``` 751 752**Description** 753 754Destroys an **OH_Drawing_Brush** object and reclaims the memory occupied by the object. 755 756@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 757 758**Parameters** 759 760| Name | Description | 761| ---------------- | ---------------------------- | 762| OH_Drawing_Brush | Pointer to an **OH_Drawing_Brush** object.| 763 764**Since** 765 7668 767 768 769### OH_Drawing_BrushGetColor() 770 771 772``` 773uint32_t OH_Drawing_BrushGetColor (const OH_Drawing_Brush * ) 774``` 775 776**Description** 777 778Obtains the color of a brush. The color is used by the brush to fill in a shape. 779 780@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 781 782**Parameters** 783 784| Name | Description | 785| ---------------- | ---------------------------- | 786| OH_Drawing_Brush | Pointer to an **OH_Drawing_Brush** object.| 787 788**Returns** 789 790Returns a 32-bit (ARGB) variable that describes the color. 791 792**Since** 793 7948 795 796 797### OH_Drawing_BrushIsAntiAlias() 798 799 800``` 801bool OH_Drawing_BrushIsAntiAlias (const OH_Drawing_Brush * ) 802``` 803 804**Description** 805 806Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. 807 808@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 809 810**Parameters** 811 812| Name | Description | 813| ---------------- | ---------------------------- | 814| OH_Drawing_Brush | Pointer to an **OH_Drawing_Brush** object.| 815 816**Returns** 817 818Returns **true** if anti-aliasing is enabled; returns **false** otherwise. 819 820**Since** 821 8228 823 824 825### OH_Drawing_BrushSetAntiAlias() 826 827 828``` 829void OH_Drawing_BrushSetAntiAlias (OH_Drawing_Brush * , bool ) 830``` 831 832**Description** 833 834Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. 835 836@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 837 838**Parameters** 839 840| Name | Description | 841| ---------------- | -------------------------------------- | 842| OH_Drawing_Brush | Pointer to an **OH_Drawing_Brush** object. | 843| bool | Whether to enable anti-aliasing. The value **true** means to enable anti-aliasing, and **false** means the opposite.| 844 845**Since** 846 8478 848 849 850### OH_Drawing_BrushSetColor() 851 852 853``` 854void OH_Drawing_BrushSetColor (OH_Drawing_Brush * , uint32_t color ) 855``` 856 857**Description** 858 859Sets the color for a brush. The color will be used by the brush to fill in a shape. 860 861@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 862 863**Parameters** 864 865| Name | Description | 866| ---------------- | ------------------------------------ | 867| OH_Drawing_Brush | Pointer to an **OH_Drawing_Brush** object. | 868| color | Color to set, which is a 32-bit (ARGB) variable.| 869 870**Since** 871 8728 873 874 875### OH_Drawing_CanvasAttachBrush() 876 877 878``` 879void OH_Drawing_CanvasAttachBrush (OH_Drawing_Canvas * , const OH_Drawing_Brush * ) 880``` 881 882**Description** 883 884Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape. 885 886@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 887 888**Parameters** 889 890| Name | Description | 891| ----------------- | ---------------------------- | 892| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 893| OH_Drawing_Brush | Pointer to an **OH_Drawing_Brush** object.| 894 895**Since** 896 8978 898 899 900### OH_Drawing_CanvasAttachPen() 901 902 903``` 904void OH_Drawing_CanvasAttachPen (OH_Drawing_Canvas * , const OH_Drawing_Pen * ) 905``` 906 907**Description** 908 909Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape. 910 911@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 912 913**Parameters** 914 915| Name | Description | 916| ----------------- | ---------------------------- | 917| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 918| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 919 920**Since** 921 9228 923 924 925### OH_Drawing_CanvasBind() 926 927 928``` 929void OH_Drawing_CanvasBind (OH_Drawing_Canvas * , OH_Drawing_Bitmap * ) 930``` 931 932**Description** 933 934Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap. (This process is called CPU rendering.) 935 936@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 937 938**Parameters** 939 940| Name | Description | 941| ----------------- | ---------------------------- | 942| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 943| OH_Drawing_Bitmap | Pointer to an **OH_Drawing_Bitmap** object.| 944 945**Since** 946 9478 948 949 950### OH_Drawing_CanvasClear() 951 952 953``` 954void OH_Drawing_CanvasClear (OH_Drawing_Canvas * , uint32_t color ) 955``` 956 957**Description** 958 959Clears a canvas by using a specified color. 960 961@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 962 963**Parameters** 964 965| Name | Description | 966| ----------------- | ------------------------------------ | 967| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object. | 968| color | Color to set, which is a 32-bit (ARGB) variable.| 969 970**Since** 971 9728 973 974 975### OH_Drawing_CanvasCreate() 976 977 978``` 979OH_Drawing_Canvas* OH_Drawing_CanvasCreate (void ) 980``` 981 982**Description** 983 984Creates an **OH_Drawing_Canvas** object. 985 986@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 987 988**Returns** 989 990Returns the pointer to the **OH_Drawing_Canvas** object created. 991 992**Since** 993 9948 995 996 997### OH_Drawing_CanvasDestroy() 998 999 1000``` 1001void OH_Drawing_CanvasDestroy (OH_Drawing_Canvas * ) 1002``` 1003 1004**Description** 1005 1006Destroys an **OH_Drawing_Canvas** object and reclaims the memory occupied by the object. 1007 1008@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1009 1010**Parameters** 1011 1012| Name | Description | 1013| ----------------- | ---------------------------- | 1014| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 1015 1016**Since** 1017 10188 1019 1020 1021### OH_Drawing_CanvasDetachBrush() 1022 1023 1024``` 1025void OH_Drawing_CanvasDetachBrush (OH_Drawing_Canvas * ) 1026``` 1027 1028**Description** 1029 1030Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. 1031 1032@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1033 1034**Parameters** 1035 1036| Name | Description | 1037| ----------------- | ---------------------------- | 1038| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 1039 1040**Since** 1041 10428 1043 1044 1045### OH_Drawing_CanvasDetachPen() 1046 1047 1048``` 1049void OH_Drawing_CanvasDetachPen (OH_Drawing_Canvas * ) 1050``` 1051 1052**Description** 1053 1054Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. 1055 1056@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1057 1058**Parameters** 1059 1060| Name | Description | 1061| ----------------- | ---------------------------- | 1062| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 1063 1064**Since** 1065 10668 1067 1068 1069### OH_Drawing_CanvasDrawLine() 1070 1071 1072``` 1073void OH_Drawing_CanvasDrawLine (OH_Drawing_Canvas * , float x1, float y1, float x2, float y2 ) 1074``` 1075 1076**Description** 1077 1078Draws a line segment. 1079 1080@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1081 1082**Parameters** 1083 1084| Name | Description | 1085| ----------------- | ---------------------------- | 1086| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 1087| x1 | X coordinate of the start point of the line segment. | 1088| y1 | Y coordinate of the start point of the line segment. | 1089| x2 | X coordinate of the end point of the line segment. | 1090| y2 | Y coordinate of the end point of the line segment. | 1091 1092**Since** 1093 10948 1095 1096 1097### OH_Drawing_CanvasDrawPath() 1098 1099 1100``` 1101void OH_Drawing_CanvasDrawPath (OH_Drawing_Canvas * , const OH_Drawing_Path * ) 1102``` 1103 1104**Description** 1105 1106Draws a path. 1107 1108@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1109 1110**Parameters** 1111 1112| Name | Description | 1113| ----------------- | ---------------------------- | 1114| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 1115| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object.| 1116 1117**Since** 1118 11198 1120 1121 1122### OH_Drawing_CanvasRestore() 1123 1124 1125``` 1126void OH_Drawing_CanvasRestore (OH_Drawing_Canvas * ) 1127``` 1128 1129**Description** 1130 1131Restores the canvas status (canvas matrix) saved on the top of the stack. 1132 1133@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1134 1135**Parameters** 1136 1137| Name | Description | 1138| ----------------- | ---------------------------- | 1139| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 1140 1141**Since** 1142 11438 1144 1145 1146### OH_Drawing_CanvasSave() 1147 1148 1149``` 1150void OH_Drawing_CanvasSave (OH_Drawing_Canvas * ) 1151``` 1152 1153**Description** 1154 1155Saves the current canvas status (canvas matrix) to the top of the stack. 1156 1157@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1158 1159**Parameters** 1160 1161| Name | Description | 1162| ----------------- | ---------------------------- | 1163| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object.| 1164 1165**Since** 1166 11678 1168 1169 1170### OH_Drawing_ColorSetArgb() 1171 1172 1173``` 1174uint32_t OH_Drawing_ColorSetArgb (uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue ) 1175``` 1176 1177**Description** 1178 1179Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color. 1180 1181@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1182 1183**Parameters** 1184 1185| Name | Description | 1186| ----- | ----------------------------------------------- | 1187| alpha | Variable that describes alpha. The value ranges from 0x00 to 0xFF.| 1188| red | Variable that describes red. The value ranges from 0x00 to 0xFF. | 1189| green | Variable that describes green. The value ranges from 0x00 to 0xFF. | 1190| blue | Variable that describes blue. The value ranges from 0x00 to 0xFF. | 1191 1192**Returns** 1193 1194Returns a 32-bit (ARGB) variable that describes the color. 1195 1196**Since** 1197 11988 1199 1200 1201### OH_Drawing_CreateFontCollection() 1202 1203 1204``` 1205OH_Drawing_FontCollection* OH_Drawing_CreateFontCollection (void ) 1206``` 1207 1208**Description** 1209 1210Creates an **OH_Drawing_FontCollection** object. 1211 1212@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1213 1214**Returns** 1215 1216Returns the pointer to the **OH_Drawing_FontCollection** object created. 1217 1218**Since** 1219 12208 1221 1222 1223### OH_Drawing_CreateTextStyle() 1224 1225 1226``` 1227OH_Drawing_TextStyle* OH_Drawing_CreateTextStyle (void ) 1228``` 1229 1230**Description** 1231 1232Creates an **OH_Drawing_TextStyle** object. 1233 1234@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1235 1236**Returns** 1237 1238Returns the pointer to the **OH_Drawing_TextStyle** object created. 1239 1240**Since** 1241 12428 1243 1244 1245### OH_Drawing_CreateTypography() 1246 1247 1248``` 1249OH_Drawing_Typography* OH_Drawing_CreateTypography (OH_Drawing_TypographyCreate * ) 1250``` 1251 1252**Description** 1253 1254Creates an **OH_Drawing_Typography** object. 1255 1256@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1257 1258**Parameters** 1259 1260| Name | Description | 1261| --------------------------- | ----------------------------------------- | 1262| OH_Drawing_TypographyCreate | Pointer to an **OH_Drawing_TypographyCreate** object.| 1263 1264**Returns** 1265 1266Returns the pointer to the **OH_Drawing_Typography** object created. 1267 1268**Since** 1269 12708 1271 1272 1273### OH_Drawing_CreateTypographyHandler() 1274 1275 1276``` 1277OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler (OH_Drawing_TypographyStyle * , OH_Drawing_FontCollection * ) 1278``` 1279 1280**Description** 1281 1282Creates an **OH_Drawing_TypographyCreate** object. 1283 1284@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1285 1286**Parameters** 1287 1288| Name | Description | 1289| -------------------------- | ------------------------------------ | 1290| OH_Drawing_TypographyStyle | Pointer to an **OH_Drawing_TypographyStyle** object.| 1291| OH_Drawing_FontCollection | Pointer to an **OH_Drawing_FontCollection** object. | 1292 1293**Returns** 1294 1295Returns the pointer to the **OH_Drawing_TypographyCreate** object created. 1296 1297**Since** 1298 12998 1300 1301 1302### OH_Drawing_CreateTypographyStyle() 1303 1304 1305``` 1306OH_Drawing_TypographyStyle* OH_Drawing_CreateTypographyStyle (void ) 1307``` 1308 1309**Description** 1310 1311Creates an **OH_Drawing_TypographyStyle** object. 1312 1313@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1314 1315**Returns** 1316 1317Returns the pointer to the **OH_Drawing_TypographyStyle** object created. 1318 1319**Since** 1320 13218 1322 1323 1324### OH_Drawing_DestroyFontCollection() 1325 1326 1327``` 1328void OH_Drawing_DestroyFontCollection (OH_Drawing_FontCollection * ) 1329``` 1330 1331**Description** 1332 1333Destroys an **OH_Drawing_FontCollection** object and reclaims the memory occupied by the object. 1334 1335@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1336 1337**Parameters** 1338 1339| Name | Description | 1340| ------------------------- | --------------------------------------- | 1341| OH_Drawing_FontCollection | Pointer to an **OH_Drawing_FontCollection** object.| 1342 1343**Since** 1344 13458 1346 1347 1348### OH_Drawing_DestroyTextStyle() 1349 1350 1351``` 1352void OH_Drawing_DestroyTextStyle (OH_Drawing_TextStyle * ) 1353``` 1354 1355**Description** 1356 1357Destroys an **OH_Drawing_TextStyle** object and reclaims the memory occupied by the object. 1358 1359@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1360 1361**Parameters** 1362 1363| Name | Description | 1364| -------------------- | ---------------------------------- | 1365| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 1366 1367**Since** 1368 13698 1370 1371 1372### OH_Drawing_DestroyTypography() 1373 1374 1375``` 1376void OH_Drawing_DestroyTypography (OH_Drawing_Typography * ) 1377``` 1378 1379**Description** 1380 1381Destroys an **OH_Drawing_Typography** object and reclaims the memory occupied by the object. 1382 1383@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1384 1385**Parameters** 1386 1387| Name | Description | 1388| --------------------- | ----------------------------------- | 1389| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 1390 1391**Since** 1392 13938 1394 1395 1396### OH_Drawing_DestroyTypographyHandler() 1397 1398 1399``` 1400void OH_Drawing_DestroyTypographyHandler (OH_Drawing_TypographyCreate * ) 1401``` 1402 1403**Description** 1404 1405Destroys an **OH_Drawing_TypographyCreate** object and reclaims the memory occupied by the object. 1406 1407@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1408 1409**Parameters** 1410 1411| Name | Description | 1412| --------------------------- | ----------------------------------------- | 1413| OH_Drawing_TypographyCreate | Pointer to an **OH_Drawing_TypographyCreate** object.| 1414 1415**Since** 1416 14178 1418 1419 1420### OH_Drawing_DestroyTypographyStyle() 1421 1422 1423``` 1424void OH_Drawing_DestroyTypographyStyle (OH_Drawing_TypographyStyle * ) 1425``` 1426 1427**Description** 1428 1429Destroys an **OH_Drawing_TypographyStyle** object and reclaims the memory occupied by the object. 1430 1431@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1432 1433**Parameters** 1434 1435| Name | Description | 1436| -------------------------- | ---------------------------------------- | 1437| OH_Drawing_TypographyStyle | Pointer to an **OH_Drawing_TypographyStyle** object.| 1438 1439**Since** 1440 14418 1442 1443 1444### OH_Drawing_PathArcTo() 1445 1446 1447``` 1448void OH_Drawing_PathArcTo (OH_Drawing_Path * , float x1, float y1, float x2, float y2, float startDeg, float sweepDeg ) 1449``` 1450 1451**Description** 1452 1453Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. 1454 1455@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1456 1457**Parameters** 1458 1459| Name | Description | 1460| --------------- | ---------------------------------------- | 1461| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object. | 1462| x1 | X coordinate of the upper left corner of the rectangle.| 1463| y1 | Y coordinate of the upper left corner of the rectangle.| 1464| x2 | X coordinate of the lower right corner of the rectangle.| 1465| y2 | Y coordinate of the lower right corner of the rectangle.| 1466| startDeg | Start angle, in degrees. | 1467| sweepDeg | Angle to sweep, in degrees. | 1468 1469**Since** 1470 14718 1472 1473 1474### OH_Drawing_PathClose() 1475 1476 1477``` 1478void OH_Drawing_PathClose (OH_Drawing_Path * ) 1479``` 1480 1481**Description** 1482 1483Closes a path. A line segment from the start point to the last point of the path is added. 1484 1485@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1486 1487**Parameters** 1488 1489| Name | Description | 1490| --------------- | ---------------------------- | 1491| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object.| 1492 1493**Since** 1494 14958 1496 1497 1498### OH_Drawing_PathCreate() 1499 1500 1501``` 1502OH_Drawing_Path* OH_Drawing_PathCreate (void ) 1503``` 1504 1505**Description** 1506 1507Creates an **OH_Drawing_Path** object. 1508 1509@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1510 1511**Returns** 1512 1513Returns the pointer to the **OH_Drawing_Path** object created. 1514 1515**Since** 1516 15178 1518 1519 1520### OH_Drawing_PathCubicTo() 1521 1522 1523``` 1524void OH_Drawing_PathCubicTo (OH_Drawing_Path * , float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY ) 1525``` 1526 1527**Description** 1528 1529Draws a cubic Bezier curve from the last point of a path to the target point. 1530 1531@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1532 1533**Parameters** 1534 1535| Name | Description | 1536| --------------- | ------------------------------ | 1537| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object. | 1538| ctrlX1 | X coordinate of the first control point.| 1539| ctrlY1 | Y coordinate of the first control point.| 1540| ctrlX2 | X coordinate of the second control point.| 1541| ctrlY2 | Y coordinate of the second control point.| 1542| endX | X coordinate of the target point. | 1543| endY | Y coordinate of the target point. | 1544 1545**Since** 1546 15478 1548 1549 1550### OH_Drawing_PathDestroy() 1551 1552 1553``` 1554void OH_Drawing_PathDestroy (OH_Drawing_Path * ) 1555``` 1556 1557**Description** 1558 1559Destroys an **OH_Drawing_Path** object and reclaims the memory occupied by the object. 1560 1561@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1562 1563**Parameters** 1564 1565| Name | Description | 1566| --------------- | ---------------------------- | 1567| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object.| 1568 1569**Since** 1570 15718 1572 1573 1574### OH_Drawing_PathLineTo() 1575 1576 1577``` 1578void OH_Drawing_PathLineTo (OH_Drawing_Path * , float x, float y ) 1579``` 1580 1581**Description** 1582 1583Draws a line segment from the last point of a path to the target point. 1584 1585@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1586 1587**Parameters** 1588 1589| Name | Description | 1590| --------------- | ---------------------------- | 1591| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object.| 1592| x | X coordinate of the target point. | 1593| y | Y coordinate of the target point. | 1594 1595**Since** 1596 15978 1598 1599 1600### OH_Drawing_PathMoveTo() 1601 1602 1603``` 1604void OH_Drawing_PathMoveTo (OH_Drawing_Path * , float x, float y ) 1605``` 1606 1607**Description** 1608 1609Sets the start point of a path. 1610 1611@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1612 1613**Parameters** 1614 1615| Name | Description | 1616| --------------- | ---------------------------- | 1617| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object.| 1618| x | X coordinate of the start point. | 1619| y | Y coordinate of the start point. | 1620 1621**Since** 1622 16238 1624 1625 1626### OH_Drawing_PathQuadTo() 1627 1628 1629``` 1630void OH_Drawing_PathQuadTo (OH_Drawing_Path * , float ctrlX, float ctrlY, float endX, float endY ) 1631``` 1632 1633**Description** 1634 1635Draws a quadratic Bezier curve from the last point of a path to the target point. 1636 1637@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1638 1639**Parameters** 1640 1641| Name | Description | 1642| --------------- | ---------------------------- | 1643| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object.| 1644| ctrlX | X coordinate of the control point. | 1645| ctrlY | Y coordinate of the control point. | 1646| endX | X coordinate of the target point. | 1647| endY | Y coordinate of the target point. | 1648 1649**Since** 1650 16518 1652 1653 1654### OH_Drawing_PathReset() 1655 1656 1657``` 1658void OH_Drawing_PathReset (OH_Drawing_Path * ) 1659``` 1660 1661**Description** 1662 1663Resets path data. 1664 1665@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1666 1667**Parameters** 1668 1669| Name | Description | 1670| --------------- | ---------------------------- | 1671| OH_Drawing_Path | Pointer to an **OH_Drawing_Path** object.| 1672 1673**Since** 1674 16758 1676 1677 1678### OH_Drawing_PenCreate() 1679 1680 1681``` 1682OH_Drawing_Pen* OH_Drawing_PenCreate (void ) 1683``` 1684 1685**Description** 1686 1687Creates an **OH_Drawing_Pen** object. 1688 1689@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1690 1691**Returns** 1692 1693Returns the pointer to the **OH_Drawing_Pen** object created. 1694 1695**Since** 1696 16978 1698 1699 1700### OH_Drawing_PenDestroy() 1701 1702 1703``` 1704void OH_Drawing_PenDestroy (OH_Drawing_Pen * ) 1705``` 1706 1707**Description** 1708 1709Destroys an **OH_Drawing_Pen** object and reclaims the memory occupied by the object. 1710 1711@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1712 1713**Parameters** 1714 1715| Name | Description | 1716| -------------- | ---------------------------- | 1717| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 1718 1719**Since** 1720 17218 1722 1723 1724### OH_Drawing_PenGetCap() 1725 1726 1727``` 1728OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap (const OH_Drawing_Pen * ) 1729``` 1730 1731**Description** 1732 1733Obtains the line cap style of a pen. 1734 1735@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1736 1737**Parameters** 1738 1739| Name | Description | 1740| -------------- | ---------------------------- | 1741| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 1742 1743**Returns** 1744 1745Returns the line cap style. 1746 1747**Since** 1748 17498 1750 1751 1752### OH_Drawing_PenGetColor() 1753 1754 1755``` 1756uint32_t OH_Drawing_PenGetColor (const OH_Drawing_Pen * ) 1757``` 1758 1759**Description** 1760 1761Obtains the color of a pen. The color is used by the pen to outline a shape. 1762 1763@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1764 1765**Parameters** 1766 1767| Name | Description | 1768| -------------- | ---------------------------- | 1769| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 1770 1771**Returns** 1772 1773Returns a 32-bit (ARGB) variable that describes the color. 1774 1775**Since** 1776 17778 1778 1779 1780### OH_Drawing_PenGetJoin() 1781 1782 1783``` 1784OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin (const OH_Drawing_Pen * ) 1785``` 1786 1787**Description** 1788 1789Obtains the line join style of a pen. 1790 1791@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1792 1793**Parameters** 1794 1795| Name | Description | 1796| -------------- | ---------------------------- | 1797| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 1798 1799**Returns** 1800 1801Returns the line join style. 1802 1803**Since** 1804 18058 1806 1807 1808### OH_Drawing_PenGetMiterLimit() 1809 1810 1811``` 1812float OH_Drawing_PenGetMiterLimit (const OH_Drawing_Pen * ) 1813``` 1814 1815**Description** 1816 1817Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. 1818 1819@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1820 1821**Parameters** 1822 1823| Name | Description | 1824| -------------- | ---------------------------- | 1825| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 1826 1827**Returns** 1828 1829Returns the miter limit. 1830 1831**Since** 1832 18338 1834 1835 1836### OH_Drawing_PenGetWidth() 1837 1838 1839``` 1840float OH_Drawing_PenGetWidth (const OH_Drawing_Pen * ) 1841``` 1842 1843**Description** 1844 1845Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. 1846 1847@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1848 1849**Parameters** 1850 1851| Name | Description | 1852| -------------- | ---------------------------- | 1853| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 1854 1855**Returns** 1856 1857Returns the thickness. 1858 1859**Since** 1860 18618 1862 1863 1864### OH_Drawing_PenIsAntiAlias() 1865 1866 1867``` 1868bool OH_Drawing_PenIsAntiAlias (const OH_Drawing_Pen * ) 1869``` 1870 1871**Description** 1872 1873Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. 1874 1875@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1876 1877**Parameters** 1878 1879| Name | Description | 1880| -------------- | ---------------------------- | 1881| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 1882 1883**Returns** 1884 1885Returns **true** if anti-aliasing is enabled; returns **false** otherwise. 1886 1887**Since** 1888 18898 1890 1891 1892### OH_Drawing_PenSetAntiAlias() 1893 1894 1895``` 1896void OH_Drawing_PenSetAntiAlias (OH_Drawing_Pen * , bool ) 1897``` 1898 1899**Description** 1900 1901Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. 1902 1903@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1904 1905**Parameters** 1906 1907| Name | Description | 1908| -------------- | -------------------------------------- | 1909| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object. | 1910| bool | Whether to enable anti-aliasing. The value **true** means to enable anti-aliasing, and **false** means the opposite.| 1911 1912**Since** 1913 19148 1915 1916 1917### OH_Drawing_PenSetCap() 1918 1919 1920``` 1921void OH_Drawing_PenSetCap (OH_Drawing_Pen * , OH_Drawing_PenLineCapStyle ) 1922``` 1923 1924**Description** 1925 1926Sets the line cap style for a pen. 1927 1928@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1929 1930**Parameters** 1931 1932| Name | Description | 1933| -------------------------- | -------------------------------- | 1934| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object. | 1935| OH_Drawing_PenLineCapStyle | Variable that describes the line cap style.| 1936 1937**Since** 1938 19398 1940 1941 1942### OH_Drawing_PenSetColor() 1943 1944 1945``` 1946void OH_Drawing_PenSetColor (OH_Drawing_Pen * , uint32_t color ) 1947``` 1948 1949**Description** 1950 1951Sets the color for a pen. The color is used by the pen to outline a shape. 1952 1953@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1954 1955**Parameters** 1956 1957| Name | Description | 1958| -------------- | ------------------------------------ | 1959| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object. | 1960| color | Color to set, which is a 32-bit (ARGB) variable.| 1961 1962**Since** 1963 19648 1965 1966 1967### OH_Drawing_PenSetJoin() 1968 1969 1970``` 1971void OH_Drawing_PenSetJoin (OH_Drawing_Pen * , OH_Drawing_PenLineJoinStyle ) 1972``` 1973 1974**Description** 1975 1976Sets the line join style for a pen. 1977 1978@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1979 1980**Parameters** 1981 1982| Name | Description | 1983| --------------------------- | -------------------------------- | 1984| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object. | 1985| OH_Drawing_PenLineJoinStyle | Variable that describes the line join style.| 1986 1987**Since** 1988 19898 1990 1991 1992### OH_Drawing_PenSetMiterLimit() 1993 1994 1995``` 1996void OH_Drawing_PenSetMiterLimit (OH_Drawing_Pen * , float miter ) 1997``` 1998 1999**Description** 2000 2001Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. 2002 2003@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2004 2005**Parameters** 2006 2007| Name | Description | 2008| -------------- | ------------------------------ | 2009| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object. | 2010| miter | Variable that describes the miter limit.| 2011 2012**Since** 2013 20148 2015 2016 2017### OH_Drawing_PenSetWidth() 2018 2019 2020``` 2021void OH_Drawing_PenSetWidth (OH_Drawing_Pen * , float width ) 2022``` 2023 2024**Description** 2025 2026Sets the thickness for a pen. This thickness determines the width of the outline of a shape. 2027 2028@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2029 2030**Parameters** 2031 2032| Name | Description | 2033| -------------- | ---------------------------- | 2034| OH_Drawing_Pen | Pointer to an **OH_Drawing_Pen** object.| 2035| width | Thickness to set, which is a variable.| 2036 2037**Since** 2038 20398 2040 2041 2042### OH_Drawing_SetTextStyleBaseLine() 2043 2044 2045``` 2046void OH_Drawing_SetTextStyleBaseLine (OH_Drawing_TextStyle * , int ) 2047``` 2048 2049**Description** 2050 2051Sets the text baseline. 2052 2053@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2054 2055**Parameters** 2056 2057| Name | Description | 2058| -------------------- | ---------------------------------- | 2059| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2060| int | Text baseline to set. For details, see the enum **OH_Drawing_TextBaseline**. | 2061 2062**Since** 2063 20648 2065 2066 2067### OH_Drawing_SetTextStyleColor() 2068 2069 2070``` 2071void OH_Drawing_SetTextStyleColor (OH_Drawing_TextStyle * , uint32_t ) 2072``` 2073 2074**Description** 2075 2076Sets the text color. 2077 2078@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2079 2080**Parameters** 2081 2082| Name | Description | 2083| -------------------- | ---------------------------------- | 2084| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2085| uint32_t | Color to set. | 2086 2087**Since** 2088 20898 2090 2091 2092### OH_Drawing_SetTextStyleDecoration() 2093 2094 2095``` 2096void OH_Drawing_SetTextStyleDecoration (OH_Drawing_TextStyle * , int ) 2097``` 2098 2099**Description** 2100 2101Sets the text decoration. 2102 2103@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2104 2105**Parameters** 2106 2107| Name | Description | 2108| -------------------- | ---------------------------------- | 2109| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2110| int | Text decoration to set. For details, see the enum **OH_Drawing_TextDecoration**. | 2111 2112**Since** 2113 21148 2115 2116 2117### OH_Drawing_SetTextStyleDecorationColor() 2118 2119 2120``` 2121void OH_Drawing_SetTextStyleDecorationColor (OH_Drawing_TextStyle * , uint32_t ) 2122``` 2123 2124**Description** 2125 2126Sets the color for the text decoration. 2127 2128@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2129 2130**Parameters** 2131 2132| Name | Description | 2133| -------------------- | ---------------------------------- | 2134| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2135| uint32_t | Color to set. | 2136 2137**Since** 2138 21398 2140 2141 2142### OH_Drawing_SetTextStyleFontFamilies() 2143 2144 2145``` 2146void OH_Drawing_SetTextStyleFontFamilies (OH_Drawing_TextStyle * , int , const char * fontFamilies[] ) 2147``` 2148 2149**Description** 2150 2151Sets the font families. 2152 2153@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2154 2155**Parameters** 2156 2157| Name | Description | 2158| -------------------- | ---------------------------------- | 2159| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2160| int | Number of font families to set. | 2161| fontFamilies | Pointer to the font families to set. | 2162 2163**Since** 2164 21658 2166 2167 2168### OH_Drawing_SetTextStyleFontHeight() 2169 2170 2171``` 2172void OH_Drawing_SetTextStyleFontHeight (OH_Drawing_TextStyle * , double ) 2173``` 2174 2175**Description** 2176 2177Sets the font height. 2178 2179@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2180 2181**Parameters** 2182 2183| Name | Description | 2184| -------------------- | ---------------------------------- | 2185| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2186| double | Font height to set. | 2187 2188**Since** 2189 21908 2191 2192 2193### OH_Drawing_SetTextStyleFontSize() 2194 2195 2196``` 2197void OH_Drawing_SetTextStyleFontSize (OH_Drawing_TextStyle * , double ) 2198``` 2199 2200**Description** 2201 2202Sets the font size. 2203 2204@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2205 2206**Parameters** 2207 2208| Name | Description | 2209| -------------------- | ---------------------------------- | 2210| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2211| double | Font size to set. | 2212 2213**Since** 2214 22158 2216 2217 2218### OH_Drawing_SetTextStyleFontStyle() 2219 2220 2221``` 2222void OH_Drawing_SetTextStyleFontStyle (OH_Drawing_TextStyle * , int ) 2223``` 2224 2225**Description** 2226 2227Sets the font style. 2228 2229@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2230 2231**Parameters** 2232 2233| Name | Description | 2234| -------------------- | ---------------------------------- | 2235| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2236| int | Font style to set. For details, see the enum **OH_Drawing_FontStyle**. | 2237 2238**Since** 2239 22408 2241 2242 2243### OH_Drawing_SetTextStyleFontWeight() 2244 2245 2246``` 2247void OH_Drawing_SetTextStyleFontWeight (OH_Drawing_TextStyle * , int ) 2248``` 2249 2250**Description** 2251 2252Sets the font weight. 2253 2254@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2255 2256**Parameters** 2257 2258| Name | Description | 2259| -------------------- | ---------------------------------- | 2260| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2261| int | Font weight to set. For details, see the enum **OH_Drawing_FontWeight**. | 2262 2263**Since** 2264 22658 2266 2267 2268### OH_Drawing_SetTextStyleLocale() 2269 2270 2271``` 2272void OH_Drawing_SetTextStyleLocale (OH_Drawing_TextStyle * , const char * ) 2273``` 2274 2275**Description** 2276 2277Sets the locale. 2278 2279@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2280 2281**Parameters** 2282 2283| Name | Description | 2284| -------------------- | ---------------------------------- | 2285| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object.| 2286| char | Pointer to the locale to set.| 2287 2288**Since** 2289 22908 2291 2292 2293### OH_Drawing_SetTypographyTextAlign() 2294 2295 2296``` 2297void OH_Drawing_SetTypographyTextAlign (OH_Drawing_TypographyStyle * , int ) 2298``` 2299 2300**Description** 2301 2302Sets the text alignment mode. 2303 2304@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2305 2306**Parameters** 2307 2308| Name | Description | 2309| -------------------------- | ---------------------------------------- | 2310| OH_Drawing_TypographyStyle | Pointer to an **OH_Drawing_TypographyStyle** object.| 2311| int | Text alignment mode to set. For details, see the enum **OH_Drawing_TextAlign**. | 2312 2313**Since** 2314 23158 2316 2317 2318### OH_Drawing_SetTypographyTextDirection() 2319 2320 2321``` 2322void OH_Drawing_SetTypographyTextDirection (OH_Drawing_TypographyStyle * , int ) 2323``` 2324 2325**Description** 2326 2327Sets the text direction. 2328 2329@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2330 2331**Parameters** 2332 2333| Name | Description | 2334| -------------------------- | ---------------------------------------- | 2335| OH_Drawing_TypographyStyle | Pointer to an **OH_Drawing_TypographyStyle** object.| 2336| int | Text direction to set. For details, see the enum **OH_Drawing_TextDirection**. | 2337 2338**Since** 2339 23408 2341 2342 2343### OH_Drawing_SetTypographyTextMaxLines() 2344 2345 2346``` 2347void OH_Drawing_SetTypographyTextMaxLines (OH_Drawing_TypographyStyle * , int ) 2348``` 2349 2350**Description** 2351 2352Sets the maximum number of lines in the text. 2353 2354@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2355 2356**Parameters** 2357 2358| Name | Description | 2359| -------------------------- | ---------------------------------------- | 2360| OH_Drawing_TypographyStyle | Pointer to an **OH_Drawing_TypographyStyle** object.| 2361| int | Maximum number of lines to set. | 2362 2363**Since** 2364 23658 2366 2367### OH_Drawing_TypographyGetAlphabeticBaseline() 2368 2369``` 2370double OH_Drawing_TypographyGetAlphabeticBaseline (OH_Drawing_Typography * ) 2371``` 2372 2373**Description** 2374 2375Obtains the alphabetic baseline. 2376 2377@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2378 2379**Parameters** 2380 2381| Name | Description | 2382| --------------------- | ----------------------------------- | 2383| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2384 2385**Returns** 2386 2387Returns the alphabetic baseline. 2388 2389**Since** 2390 23919 2392 2393### OH_Drawing_TypographyGetHeight() 2394 2395``` 2396double OH_Drawing_TypographyGetHeight (OH_Drawing_Typography * ) 2397``` 2398 2399**Description** 2400 2401Obtains the height. 2402 2403@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2404 2405**Parameters** 2406 2407| Name | Description | 2408| --------------------- | ----------------------------------- | 2409| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2410 2411**Returns** 2412 2413Returns the height. 2414 2415**Since** 2416 24179 2418 2419### OH_Drawing_TypographyGetIdeographicBaseline() 2420 2421``` 2422double OH_Drawing_TypographyGetIdeographicBaseline (OH_Drawing_Typography * ) 2423``` 2424 2425**Description** 2426 2427Obtains the ideographic baseline. 2428 2429@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2430 2431**Parameters** 2432 2433| Name | Description | 2434| --------------------- | ----------------------------------- | 2435| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2436 2437**Returns** 2438 2439Returns the ideographic baseline. 2440 2441**Since** 2442 24439 2444 2445### OH_Drawing_TypographyGetLongestLine() 2446 2447**Description** 2448 2449Obtains the longest line. 2450 2451@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2452 2453**Parameters** 2454 2455| Name | Description | 2456| --------------------- | ----------------------------------- | 2457| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2458 2459**Returns** 2460 2461Returns the longest line. 2462 2463**Since** 2464 24659 2466 2467### OH_Drawing_TypographyGetMaxIntrinsicWidth() 2468 2469``` 2470double OH_Drawing_TypographyGetMaxIntrinsicWidth (OH_Drawing_Typography * ) 2471``` 2472 2473**Description** 2474 2475Obtains the maximum intrinsic width. 2476 2477@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2478 2479**Parameters** 2480 2481| Name | Description | 2482| --------------------- | ----------------------------------- | 2483| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2484 2485**Returns** 2486 2487Returns the maximum intrinsic width. 2488 2489**Since** 2490 24919 2492 2493### OH_Drawing_TypographyGetMaxWidth() 2494 2495``` 2496double OH_Drawing_TypographyGetMaxWidth (OH_Drawing_Typography * ) 2497``` 2498 2499**Description** 2500 2501Obtains the maximum width. 2502 2503@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2504 2505**Parameters** 2506 2507| Name | Description | 2508| --------------------- | ----------------------------------- | 2509| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2510 2511**Returns** 2512 2513Returns the maximum width. 2514 2515**Since** 2516 25179 2518 2519### OH_Drawing_TypographyGetMinIntrinsicWidth() 2520 2521``` 2522double OH_Drawing_TypographyGetMinIntrinsicWidth (OH_Drawing_Typography * ) 2523``` 2524 2525**Description** 2526 2527Obtains the minimum intrinsic width. 2528 2529@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2530 2531**Parameters** 2532 2533| Name | Description | 2534| --------------------- | ----------------------------------- | 2535| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2536 2537**Returns** 2538 2539Returns the minimum intrinsic width. 2540 2541**Since** 2542 25439 2544 2545### OH_Drawing_TypographyHandlerAddText() 2546 2547 2548``` 2549void OH_Drawing_TypographyHandlerAddText (OH_Drawing_TypographyCreate * , const char * ) 2550``` 2551 2552**Description** 2553 2554Sets the text content. 2555 2556@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2557 2558**Parameters** 2559 2560| Name | Description | 2561| --------------------------- | ----------------------------------------- | 2562| OH_Drawing_TypographyCreate | Pointer to an **OH_Drawing_TypographyCreate** object.| 2563| char | Pointer to the text content to set. | 2564 2565**Since** 2566 25678 2568 2569 2570### OH_Drawing_TypographyHandlerPopTextStyle() 2571 2572 2573``` 2574void OH_Drawing_TypographyHandlerPopTextStyle (OH_Drawing_TypographyCreate * ) 2575``` 2576 2577**Description** 2578 2579Removes the topmost style in the stack, leaving the remaining styles in effect. 2580 2581@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2582 2583**Parameters** 2584 2585| Name | Description | 2586| --------------------------- | ----------------------------------------- | 2587| OH_Drawing_TypographyCreate | Pointer to an **OH_Drawing_TypographyCreate** object.| 2588 2589**Since** 2590 25918 2592 2593 2594### OH_Drawing_TypographyHandlerPushTextStyle() 2595 2596 2597``` 2598void OH_Drawing_TypographyHandlerPushTextStyle (OH_Drawing_TypographyCreate * , OH_Drawing_TextStyle * ) 2599``` 2600 2601**Description** 2602 2603Sets the text style. 2604 2605@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2606 2607**Parameters** 2608 2609| Name | Description | 2610| --------------------------- | ----------------------------------------- | 2611| OH_Drawing_TypographyCreate | Pointer to an **OH_Drawing_TypographyCreate** object.| 2612| OH_Drawing_TextStyle | Pointer to an **OH_Drawing_TextStyle** object. | 2613 2614**Since** 2615 26168 2617 2618 2619### OH_Drawing_TypographyLayout() 2620 2621 2622``` 2623void OH_Drawing_TypographyLayout (OH_Drawing_Typography * , double ) 2624``` 2625 2626**Description** 2627 2628Lays out the typography. 2629 2630@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2631 2632**Parameters** 2633 2634| Name | Description | 2635| --------------------- | ----------------------------------- | 2636| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2637| double | Maximum text width to set. | 2638 2639**Since** 2640 26418 2642 2643 2644### OH_Drawing_TypographyPaint() 2645 2646 2647``` 2648void OH_Drawing_TypographyPaint (OH_Drawing_Typography * , OH_Drawing_Canvas * , double , double ) 2649``` 2650 2651**Description** 2652 2653Paints text on the canvas. 2654 2655@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2656 2657**Parameters** 2658 2659| Name | Description | 2660| --------------------- | ----------------------------------- | 2661| OH_Drawing_Typography | Pointer to an **OH_Drawing_Typography** object.| 2662| OH_Drawing_Canvas | Pointer to an **OH_Drawing_Canvas** object. | 2663| double | X coordinate. | 2664| double | Y coordinate. | 2665 2666**Since** 2667 26688 2669