diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 38ea644f359e53892c949eb6f499df748d079975..f056846fd40d2d6d9dbf9c7ccea5626d4af8b716 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -497,6 +497,38 @@ typedef struct OH_Drawing_Font_Metrics { */ float OH_Drawing_FontGetMetrics(OH_Drawing_Font*, OH_Drawing_Font_Metrics*); +/** + * @brief Retrieves the bound rect for each glyph in glyph array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param glyphs Indicates the array of glyph indices to be measured. + * @param count Indicates the number of glyphs. + * @param OH_Drawing_Array The bound rect array for each glyph, returned to the caller. + * @since 14 + * @version 1.0 + * @note OH_Drawing_Array object must be allocated by OH_Drawing_RectCreateArray function. + * @note Size of OH_Drawing_Array must be bigger than glyph counts. + * @note OH_Drawing_Rect use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. + * @note OH_Drawing_Rect use two points(left-bottom & right-top) to describe the bound. + * @note The bound rect will be snap to integral boundaries. + */ +void OH_Drawing_FontGetBounds(const OH_Drawing_Font*, const uint16_t* glyphs, int count, OH_Drawing_Array*); + +/** + * @brief Create a path object for specified Glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param glyph glyph index to be obtained. + * @return Returns an OH_Drawing_Path object of specified glyph index, return nullptr if error happened. + * @since 14 + * @version 1.0 + * @note OH_Drawing_Path use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. + * @note Return value must be released by OH_Drawing_PathDestroy function. + */ +OH_Drawing_Path* OH_Drawing_FontCreatePathForGlyph(OH_Drawing_Font*, uint16_t glyph); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_rect.h b/graphic/graphic_2d/native_drawing/drawing_rect.h index e07abff68df1f0ac2cd19ec03a9dacac6565144f..68d240f9391c4bb299d652f91382152ffca08059 100644 --- a/graphic/graphic_2d/native_drawing/drawing_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_rect.h @@ -214,6 +214,54 @@ void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst); */ void OH_Drawing_RectDestroy(OH_Drawing_Rect*); +/** + * @brief Creates an OH_Drawing_Array object, which is used to store multiple OH_Drawing_Rect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param size Indicates the size of the array object + * @return Returns the pointer to the OH_Drawing_Array object created. + * @since 14 + * @version 1.0 + * @note OH_Drawing_Array must be release by OH_Drawing_RectDestroyArray function. + * @note Return nullptr if size invalid. + */ +OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size); + +/** + * @brief Return the size of an OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates the array object + * @return The size of the array object + * @since 14 + * @version 1.0 + * @note Return zero if OH_Drawing_Array invalid. + */ +size_t OH_Drawing_RectGetArraySize(OH_Drawing_Array*); + +/** + * @brief return the specified OH_Drawing_Rect object from OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArr Indicates the array object + * @param index Indicates the index of array, caller must make sure the index is valid. + * @return Returns the pointer to the OH_Drawing_Rect object. + * @since 14 + * @version 1.0 + * @note Return nullptr if OH_Drawing_Array or index invalid. + */ +OH_Drawing_Rect* OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArr, size_t index); + +/** + * @brief Destroys an array OH_Drawing_Rect object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates the pointer to an OH_Drawing_Array object. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_RectDestroyArray(OH_Drawing_Array*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index edcc71cb8345836bc9647825ebc47b6d0ff63173..3debd6c96eb1ee5412173af3b96abd048471fb62 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -167,6 +167,15 @@ typedef struct OH_Drawing_PathEffect OH_Drawing_PathEffect; */ typedef struct OH_Drawing_Rect OH_Drawing_Rect; +/** + * @brief Defines an array object, which is used to store multiple NDK object. + * + * @since 13 + * @version 1.0 + */ + +typedef struct OH_Drawing_Array OH_Drawing_Array; + /** * @brief Defines a roundRect, which is used to describe the round rectangle. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index f0d6835c1e41a25d9e5b1d28eff675a8e46fb7f0..99d76e616ae84ccb18beeea31bf513d3a3aa393e 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1441,5 +1441,29 @@ { "first_introduced": "12", "name":"OH_Drawing_SetTextShadow" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_FontGetBounds" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_FontCreatePathForGlyph" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectCreateArray" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectGetArraySize" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectGetArrayElement" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectDestroyArray" } ] \ No newline at end of file