From 26521bfcef4b0a11c7621b12c964c610b70e5ceb 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 --- graphic/graphic_2d/native_drawing/BUILD.gn | 2 + .../native_drawing/drawing_text_declaration.h | 8 ++ .../drawing_text_lineTypography.h | 99 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 16 +++ 4 files changed, 125 insertions(+) create mode 100644 graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index aea6e1dc4..5222b1be6 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -50,6 +50,7 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_surface.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_blob.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_declaration.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_typography.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_typeface.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_types.h", @@ -95,6 +96,7 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_surface.h", "native_drawing/drawing_text_blob.h", "native_drawing/drawing_text_declaration.h", + "native_drawing/drawing_text_lineTypography.h", "native_drawing/drawing_text_typography.h", "native_drawing/drawing_typeface.h", "native_drawing/drawing_types.h", diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index 9a324c807..2da27a1c6 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 14 + * @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_lineTypography.h b/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h new file mode 100644 index 000000000..570a2c7ec --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved. + * 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 DRAWING_TEXT_LINETYPOGRAPHY_H +#define DRAWING_TEXT_LINETYPOGRAPHY_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides the 2D drawing capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 14 + * @version 1.0 + */ + +/** + * @file drawing_text_linetypography.h + * + * @brief Declares functions related to lineTypography in the drawing module. + * + * @kit ArkGraphics2D + * @library libnative_drawing.so + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @since 14 + * @version 1.0 + */ + +#include "cstddef" +#include "drawing_text_declaration.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @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 14 + */ +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 14 + */ +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 14 + */ +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. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 14 + */ +OH_Drawing_TextLine* OH_Drawing_LineTypographyCreateLine(OH_Drawing_LineTypography* lineTypography, + size_t startIndex, size_t count); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 252c8c254..6ca1e2335 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1469,5 +1469,21 @@ { "first_introduced": "13", "name":"OH_Drawing_RecordCmdDestroy" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_CreateLineTypography" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_DestroyLineTypography" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_LineTypographyGetLineBreak" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_LineTypographyCreateLine" } ] \ No newline at end of file -- Gitee