diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index 542012e2af96ab4602bfab5555598f97724a156b..a63fb79fcbef87aa816beb681dd4c5f3b6cf1aff 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h @@ -57,6 +57,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. * @@ -122,6 +130,14 @@ typedef struct OH_Drawing_FontParser OH_Drawing_FontParser; */ typedef struct OH_Drawing_TextShadow OH_Drawing_TextShadow; +/** + * @brief Defines an OH_Drawing_TextLine, which is used to manager the text line in paragraph. + * + * @since 13 + * @version 1.0 + */ +typedef struct OH_Drawing_TextLine OH_Drawing_TextLine; + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_line.h b/graphic/graphic_2d/native_drawing/drawing_text_line.h new file mode 100755 index 0000000000000000000000000000000000000000..9a15571e499ed7270b563a8f599115e4a8b0c813 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_line.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_TEXT_LINE_H +#define C_INCLUDE_DRAWING_TEXT_LINE_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 11 + * @version 1.0 + */ + +/** + * @file drawing_text_line.h + * + * @brief Declares functions related to the textLine object in the drawing module. + * + * @since 13 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Destroys an OH_Drawing_TextLine object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextLine Indicates the pointer to an OH_Drawing_TextLine object. + * @since 13 + * @version 1.0 + */ +void OH_Drawing_TextLineDestroy(OH_Drawing_TextLine*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 2d879cd9f1ee519ae477e69d019f93c8d5771738..26434d46c2aae7db94d8ddb8dc812bb3c4eae27c 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -2750,6 +2750,54 @@ 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*); + +/** + * @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*); + +/** + * @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*, 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, it means the text range is + * from start index to the end of string. + * @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*, 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 37535bc2b3cc673a3dacd154c9366bd9cd5ed9c0..2d1ad865c884e32b099ceebe0aa5bfb30c4ad0d8 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1453,5 +1453,25 @@ { "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" + }, + { + "first_introduced": "13", + "name": "OH_Drawing_TextLineDestroy" } ] \ No newline at end of file