From 4e444579d2261fb722c743cc56b76d6afb0983a9 Mon Sep 17 00:00:00 2001 From: changleipeng Date: Mon, 29 Jul 2024 10:30:06 +0800 Subject: [PATCH] update LineTypeset Signed-off-by: changleipeng Change-Id: I2f4c65d8b45afdfdc037822c435e8d7280562a6e Signed-off-by: changleipeng --- .../native_drawing/drawing_text_declaration.h | 8 +++ .../native_drawing/drawing_text_typography.h | 49 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 16 ++++++ 3 files changed, 73 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index 9a324c807..9a523e756 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h @@ -60,6 +60,14 @@ typedef struct OH_Drawing_FontCollection OH_Drawing_FontCollection; */ typedef struct OH_Drawing_Typography OH_Drawing_Typography; +/** + * @brief Defines an OH_Drawing_LineTypography, which is used to perform line layout. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_LineTypography OH_Drawing_LineTypography; + /** * @brief Defines an OH_Drawing_TextStyle, which is used to manage text colors and decorations. * diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index d821c3855..d9b81c7bb 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -2753,6 +2753,55 @@ void OH_Drawing_TypographyDestroyTextBox(OH_Drawing_TextBox*); void OH_Drawing_SetTextShadow(OH_Drawing_TextShadow* shadow, uint32_t color, OH_Drawing_Point* offset, double blurRadius); +/** + * @brief Creates an OH_Drawing_LineTypography object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyCreate Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @return Returns the pointer to the OH_Drawing_LineTypography object created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_LineTypography* OH_Drawing_CreateLineTypography(OH_Drawing_TypographyCreate* handler); + +/** + * @brief Releases the memory occupied by an OH_Drawing_LineTypography object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_LineTypography Indicates the pointer to an OH_Drawing_LineTypography object. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_DestroyLineTypography(OH_Drawing_LineTypography* lineTypography); + +/** + * @brief Calculate the line breakpoint based on the width provided. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyCreate Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @param startIndex Indicates the starting point for the line-break calculations. + * @param width Indicates the requested line-break width. + * @return Returns the count of the characters from startIndex that would cause the line break. + * @since 13 + * @version 1.0 + */ +size_t OH_Drawing_LineTypographyGetLineBreak(OH_Drawing_LineTypography* lineTypography, + size_t startIndex, double width); + +/** + * @brief Creates a text line object based on the text range provided. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_LineTypography Indicates the pointer to an OH_Drawing_TypographyCreate object. + * @param startIndex Indicates the starting index of the text range. + * @param count Indicates the characters count of the text range. If the value is set to 0, return nullptr. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 13 + * @version 1.0 + */ +OH_Drawing_TextLine* OH_Drawing_LineTypographyCreateLine(OH_Drawing_LineTypography* lineTypography, + size_t startIndex, size_t count); + #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..0f93c67a1 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1441,5 +1441,21 @@ { "first_introduced": "12", "name":"OH_Drawing_SetTextShadow" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_CreateLineTypography" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_DestroyLineTypography" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_LineTypographyGetLineBreak" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_LineTypographyCreateLine" } ] \ No newline at end of file -- Gitee