From eb306c896071e9ba765aa1e3864f7a108a35e508 Mon Sep 17 00:00:00 2001 From: changleipeng Date: Sat, 3 Aug 2024 11:34:13 +0800 Subject: [PATCH] add ndk interface for path and bound obtain for font glyph Signed-off-by: changleipeng --- .../graphic_2d/native_drawing/drawing_font.h | 26 ++++++++++++++ .../graphic_2d/native_drawing/drawing_rect.h | 34 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 20 +++++++++++ 3 files changed, 80 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 38ea644f3..b86168393 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -497,6 +497,32 @@ typedef struct OH_Drawing_Font_Metrics { */ float OH_Drawing_FontGetMetrics(OH_Drawing_Font*, OH_Drawing_Font_Metrics*); +/** + * @brief Retrieves the bound for each glyph in glyphs. + * + * @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 bounds Indicates the bound for each glyph returned to the caller. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_FontGetBounds(const OH_Drawing_Font*, const uint16_t* glyphs, int count, OH_Drawing_Rect* bounds); + +/** + * @brief create a path object of 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 measured. + * @return Returns an OH_Drawing_Path object, must be release by OH_Drawing_PathDestroy + * Returns nullptr if OH_Drawing_Font is nullptr. + * @since 13 + * @version 1.0 + */ +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 e07abff68..c3b5dfc00 100644 --- a/graphic/graphic_2d/native_drawing/drawing_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_rect.h @@ -214,6 +214,40 @@ void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst); */ void OH_Drawing_RectDestroy(OH_Drawing_Rect*); +/** + * @brief Creates an array of OH_Drawing_Rect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param size Indicates the size of the array + * @return Returns the pointer to the array OH_Drawing_Rect object created. + * Must be release by OH_Drawing_RectDestroyArray interface + * @since 13 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_RectCreateArray(uint16_t size); + +/** + * @brief return the specified OH_Drawing_Rect object from 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 array OH_Drawing_Rect object. + * @since 13 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_RectGetArrayElement(OH_Drawing_Rect* rectArr, uint16_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_Rect Indicates the pointer to an array OH_Drawing_Rect object. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_RectDestroyArray(OH_Drawing_Rect*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index f0d6835c1..3e2e1f913 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1441,5 +1441,25 @@ { "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_RectGetArrayElement" + }, + { + "first_introduced": "13", + "name":"OH_Drawing_RectDestroyArray" } ] \ No newline at end of file -- Gitee