From 969293ed3ccf4f30241ad9c469e1d028133c014d Mon Sep 17 00:00:00 2001 From: changleipeng Date: Mon, 29 Jul 2024 10:30:06 +0800 Subject: [PATCH 1/2] update NDK interface Signed-off-by: changleipeng Change-Id: I2f4c65d8b45afdfdc037822c435e8d7280562a6e --- .../kit_sub_system/c_file_kit_sub_system.json | 15 + graphic/graphic_2d/native_drawing/BUILD.gn | 8 + .../graphic_2d/native_drawing/drawing_font.h | 55 ++++ .../graphic_2d/native_drawing/drawing_rect.h | 59 ++++ .../native_drawing/drawing_text_declaration.h | 32 ++ .../drawing_text_font_descriptor.h | 190 ++++++++++++ .../native_drawing/drawing_text_line.h | 283 ++++++++++++++++++ .../drawing_text_lineTypography.h | 103 +++++++ .../native_drawing/drawing_text_run.h | 225 ++++++++++++++ .../native_drawing/drawing_text_typography.h | 123 ++++++-- .../graphic_2d/native_drawing/drawing_types.h | 21 ++ .../native_drawing/libnative_drawing.ndk.json | 232 ++++++++++++++ 12 files changed, 1317 insertions(+), 29 deletions(-) create mode 100644 graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h create mode 100644 graphic/graphic_2d/native_drawing/drawing_text_line.h create mode 100644 graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h create mode 100644 graphic/graphic_2d/native_drawing/drawing_text_run.h diff --git a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json index 668e349de..44c8cffcf 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json +++ b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json @@ -269,6 +269,21 @@ "kitName": "ArkGraphicsD", "subSystem": "图形图像" }, + { + "filePath": "graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h", + "kitName": "ArkGraphicsD", + "subSystem": "图形图像" + }, + { + "filePath": "graphic/graphic_2d/native_drawing/drawing_text_line.h", + "kitName": "ArkGraphicsD", + "subSystem": "图形图像" + }, + { + "filePath": "graphic/graphic_2d/native_drawing/drawing_text_run.h", + "kitName": "ArkGraphicsD", + "subSystem": "图形图像" + }, { "filePath": "graphic/graphic_2d/native_drawing/drawing_text_typography.h", "kitName": "ArkGraphicsD", diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index aea6e1dc4..88c0459bc 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -50,6 +50,10 @@ 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_font_descriptor.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_line.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_run.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 +99,10 @@ 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_font_descriptor.h", + "native_drawing/drawing_text_line.h", + "native_drawing/drawing_text_lineTypography.h", + "native_drawing/drawing_text_run.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_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 38ea644f3..0f0428395 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -497,6 +497,61 @@ 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 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 The bound rect array for each glyph, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, glyphs + * and bounds is nullptr or count is 0. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_FontGetBounds(const OH_Drawing_Font* font, const uint16_t* glyphs, uint32_t count, + OH_Drawing_Array* bounds); + +/** + * @brief Retrieves the path for specified Glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param font Indicates the pointer to an OH_Drawing_Font object. + * @param glyph glyph index to be obtained. + * @param path The path object, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, path + * is nullptr or glyph not exist. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_FontGetPathForGlyph(const OH_Drawing_Font* font, uint16_t glyph, + OH_Drawing_Path* path); + +/** + * @brief Get the text outline path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param font Indicates the pointer to an OH_Drawing_Font object. + * @param text Indicates the character storage encoded with text encoding. + * @param byteLength Indicates the text length in bytes. + * @param encoding Indicates the text encoding. + * @param x Indicates x coordinates of the text. + * @param y Indicates y coordinates of the text. + * @param path The path object, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, text or path is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_FontGetTextPath(const OH_Drawing_Font* font, const void* text, size_t byteLength, + OH_Drawing_TextEncoding encoding, float x, float y, OH_Drawing_Path* path); + #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..02c134f2b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_rect.h @@ -214,6 +214,65 @@ 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. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty, + * or size is invalid. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size); + +/** + * @brief Gets the size of an OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArray Indicates the array object. + * @param pSize Indicates the size pointer. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or pSize is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize); + +/** + * @brief Gets the specified OH_Drawing_Rect object from OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArray Indicates the array object. + * @param index Indicates the index of array, caller must make sure the index is valid. + * @param rect Pointers to Pointer of OH_Drawing_Rect object, returned to the caller. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or pprect is nullptr, + * or index is valid. + * @since 14 + * @version 1.0 + * @note Return nullptr if OH_Drawing_Array or index invalid. + */ +OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index, + OH_Drawing_Rect** rect); + +/** + * @brief Destroys an array OH_Drawing_Rect object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rectArray Indicates the pointer to an OH_Drawing_Array object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index 9a324c807..24ec0b365 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. * @@ -125,6 +133,30 @@ typedef struct OH_Drawing_FontParser OH_Drawing_FontParser; */ typedef struct OH_Drawing_TextShadow OH_Drawing_TextShadow; +/** + * @brief Defines an OH_Drawing_TextTab, which is used to to store the tab alignment type and position. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_TextTab OH_Drawing_TextTab; + +/** + * @brief Defines an OH_Drawing_TextLine, which is used to manage text line. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_TextLine OH_Drawing_TextLine; + +/** + * @brief Defines an OH_Drawing_Run, which is used to manage run. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_Run OH_Drawing_Run; + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h new file mode 100644 index 000000000..270e7c602 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2021-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_FONT_DESCRIPTOR_H +#define C_INCLUDE_DRAWING_TEXT_FONT_DESCRIPTOR_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides the font descriptor capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_text_font_descriptor.h + * + * @brief Provide the ability to provide OH_Drawing_FontDescriptor. + * + * @kit ArkGraphics2D + * @library libnative_drawing.so + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @since 8 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Type style flag. + * + * @since 14 + * @version 1.0 + */ +typedef enum { + /** Italic font */ + ITALIC = 1 << 0, + /** Bold font */ + BOLD = 1 << 1, +} OH_Drawing_FontTypeStyle; + +/** + * @brief An enumeration of system font types. + * + * @since 14 + * @version 1.0 + */ +typedef enum { + /** All font types */ + ALL = 1 << 0, + /** System generic font type */ + GENERIC = 1 << 1, + /** Stylish font type */ + STYLISH = 1 << 2, + /** Installed font types */ + INSTALLED = 1 << 3, +} OH_Drawing_SystemFontType; + +/** + * @brief Describes the font information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontDescriptor { + /** The file path of System font */ + char* path; + /** A name that uniquely identifies the font */ + char* postScriptName; + /** The name of System font */ + char* fullName; + /** The family of System font */ + char* fontFamily; + /** The subfont family of the system font */ + char* fontSubfamily; + /** The weight of System font */ + int weight; + /** The width of System font */ + int width; + /** Whether the system font is tilted */ + int italic; + /** Whether the system font is compact */ + bool monoSpace; + /** whether symbolic fonts are supported */ + bool symbolic; + /** Font size */ + size_t size; + /** Font style flag, from OH_Drawing_FontTypeStyle */ + int typeStyle; +} OH_Drawing_FontDescriptor; + +/** + * @brief Obtain all system font descriptive symbols that match the specified font descriptor. Where the 'path' and + * 'size' fields are not considered as valid matching values, It takes effect when the remaining fields are not + * default values, If all the fields of the parameters OH_Drawing_FontDescriptor are default, obtain all system + * font descriptors. If the match fails, return nullptr. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontDescriptor The pointer to the OH_Drawing_FontDescriptor object. It is recommended to + * use OH_Drawing_CreateFontDescriptor to obtain a valid OH_Drawing_FontDescriptor instance. If you create your own + * OH_Drawing_FontDescriptor object, ensure that fields not intended for matching are set to their default values. + * @param size_t Indicates the count of obtained OH_Drawing_FontDescriptor. + * @return Returns an array of OH_Drawing_FontDescriptor. + * @since 14 + * @version 1.0 + */ +OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescriptor*, size_t*); + +/** + * @brief Releases the OH_Drawing_FontDescriptor array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontDescriptor Pointer to OH_Drawing_FontDescriptor array. + * @param size_t Represents the number of members of the OH_Drawing_FontDescriptor array. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor*, size_t); + +/** + * @brief Get the OH_Drawing_FontDescriptor object by the full name of the font, supporting generic fonts, + * stylish fonts, and installed fonts. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_String* Indicates the full name object OH_Drawing_String. + * @return Returns the pointer to a font descriptor object OH_Drawing_FontDescriptor. + * @since 14 + * @version 1.0 + */ +OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String*); + +/** + * @brief Obtain the corresponding font full name list by the font type. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_SystemFontType Indicates enumerates of system font type. + * @return Returns the pointer to full name array object OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontType); + +/** + * @brief Get the specified full name object OH_Drawing_String by index from the + * OH_Drawing_Array object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates an array of full name object OH_Drawing_Array. + * @param size_t The index of full name. + * @return Returns a full name object OH_Drawing_String. + * @since 14 + * @version 1.0 + */ +const OH_Drawing_String* OH_Drawing_GetSystemFontFullNamesElement(OH_Drawing_Array*, size_t); + +/** + * @brief Releases the memory occupied by a list of system font names. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array Indicates an array of full name. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file 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 100644 index 000000000..e83eead09 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_line.h @@ -0,0 +1,283 @@ +/* + * 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 the 2D drawing capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 14 + * @version 1.0 + */ + +/** + * @file drawing_text_line.h + * + * @brief Declares functions related to textLine in the drawing module. + * + * @since 14 + * @version 1.0 + */ + +#include "drawing_text_declaration.h" +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get text line information. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Typography Indicates the pointer to a typography object OH_Drawing_Typography. + * @return Indicates the pointer to a text line array object OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_TypographyGetTextLines(OH_Drawing_Typography* typography); + +/** + * @brief Releases the memory occupied by the text line array object OH_Drawing_Array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param lines Indicates the pointer to the text line array object OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyTextLines(OH_Drawing_Array* lines); + +/** + * @brief Releases the memory occupied by the text line object OH_Drawing_TextLine. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to the text line object OH_Drawing_TextLine. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyTextLine(OH_Drawing_TextLine* line); + +/** + * @brief Get the text line object by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param lines Indicates the pointer to the text line array object OH_Drawing_Array. + * @param index text line object index. + * @return Indicates the pointer to a text line object OH_Drawing_TextLine. + * @since 14 + * @version 1.0 + */ +OH_Drawing_TextLine* OH_Drawing_GetTextLinesIndex(OH_Drawing_Array* lines, size_t index); + +/** + * @brief Get the count of glyphs. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the count of glyphs. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetGlyphCount(OH_Drawing_TextLine* line); + +/** + * @brief Get the range of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param start Indicates the pointer to text line start position. + * @param end Indicates the pointer to text line end position. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_TextLineGetTextRange(OH_Drawing_TextLine* line, size_t* start, size_t* end); + +/** + * @brief Get the glyph runs array of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Indicates the pointer to a glyph runs array object of text line OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_TextLineGetGlyphRuns(OH_Drawing_TextLine* line); + +/** + * @brief Releases the memory occupied by the run array object OH_Drawing_Array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param runs Indicates the pointer to the run array object OH_Drawing_Array. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyRuns(OH_Drawing_Array* runs); + +/** + * @brief Get the run object by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param runs Indicates the pointer to the run array object OH_Drawing_Array. + * @param index run object index. + * @return Indicates the pointer to a run object OH_Drawing_Run. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Run* OH_Drawing_GetRunsIndex(OH_Drawing_Array* runs, size_t index); + +/** + * @brief Paint the range of text line. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param canvas Draw the text line on the canvas. + * @param x Represents the X-axis position on the canvas. + * @param y Represents the Y-axis position on the canvas. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_TextLinePaint(OH_Drawing_TextLine* line, OH_Drawing_Canvas* canvas, double x, double y); + +/** + * @brief Creates a truncated text line object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param width Indicates the text line width to set. + * @param mode Indicates the ellipsis model to set, EllipsisMode:MIDDLE is not supported. + * For details, see the enum OH_Drawing_EllipsisModal. + * @param ellipsis Indicates the ellipsis string to set. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_TextLine* OH_Drawing_TextLineCreateTruncatedLine(OH_Drawing_TextLine* line, double width, int mode, + const char* ellipsis); + +/** + * @brief Gets the text line typographic bounds. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param ascent Indicates the distance that the pointer points to remain above the baseline. + * @param descent Indicates the pointer to the distance that remains below the baseline. + * @param leading Indicates the pointer to the line Spacing. + * @return Returns The total width of the typesetting border. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetTypographicBounds(OH_Drawing_TextLine* line, double* ascent, double* descent, + double* leading); + +/** + * @brief Gets the text line image bounds. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the pointer to the OH_Drawing_Rect struct created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_TextLineGetImageBounds(OH_Drawing_TextLine* line); + +/** + * @brief Gets the tail space width. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @return Returns the tail space width. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetTrailingSpaceWidth(OH_Drawing_TextLine* line); + +/** + * @brief Gets the string index of the given position. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param point The given position. + * @return Returns the string index for a given position. + * @since 14 + * @version 1.0 + */ +int32_t OH_Drawing_TextLineGetStringIndexForPosition(OH_Drawing_TextLine* line, OH_Drawing_Point* point); + +/** + * @brief Gets the offset of the given string index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param index The given string index. + * @param secondOffset Indicates the pointer to the offset of compound character, not supported. + * @return Returns the offset info for a given string index. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetOffsetForStringIndex(OH_Drawing_TextLine* line, int32_t index, double* secondOffset); + +/** + * @brief User-defined callback functions for using offsets and indexes. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param offset Character offset is traversed as an argument to the callback function. + * @param index Character index is traversed as an argument to the callback function. + * @param leadingEdge Whether the current offset is at the character front, as an argument to the callback function. + * @return The return value of the user-defined callback function. + * If false is returned, the traversal continues. + * If true is returned, the traversal stops. + * @since 14 + * @version 1.0 + */ +typedef bool (*CustomCallback)(double offset, int32_t index, bool leadingEdge); + +/** + * @brief Enumerate caret offset and index in text lines. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param callback User-defined callback functions, see CustomCallback. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_TextLineEnumerateCaretOffsets(OH_Drawing_TextLine* line, CustomCallback callback); + +/** + * @brief Gets the text offset based on the given alignment factor and alignment width. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param line Indicates the pointer to an OH_Drawing_TextLine object. + * @param alignmentFactor The coefficients that text needs to be aligned. + * Less than or equal to 0 is left justified, 0.5 is center justified, + * and greater than or equal to 1 is right justified. + * @param alignmentWidth The width of the text to be aligned. + * Returns 0 if it is less than the actual width of the text. + * @return Returns the offset of the aligned text. + * @since 14 + * @version 1.0 + */ +double OH_Drawing_TextLineGetAlignmentOffset(OH_Drawing_TextLine* line, double alignmentFactor, double alignmentWidth); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // C_INCLUDE_DRAWING_TEXT_LINE_H \ No newline at end of file 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..f480cd643 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h @@ -0,0 +1,103 @@ +/* + * 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 C_INCLUDE_DRAWING_TEXT_LINETYPOGRAPHY_H +#define C_INCLUDE_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 + * @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 14 + * @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 14 + * @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. + * @return Returns the pointer to the OH_Drawing_TextLine object created. + * @since 14 + * @version 1.0 + */ +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/drawing_text_run.h b/graphic/graphic_2d/native_drawing/drawing_text_run.h new file mode 100644 index 000000000..28949dc42 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_run.h @@ -0,0 +1,225 @@ +/* + * 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_RUN_H +#define C_INCLUDE_DRAWING_TEXT_RUN_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides the text run capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 14 + * @version 1.0 + */ + +/** + * @file drawing_text_run.h + * + * @brief Declares functions related to run in the drawing module. + * + * @since 14 + * @version 1.0 + */ + +#include "drawing_text_declaration.h" +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief Gets the run glyph indices ,the offset of the index relative to the entire paragraph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param start The run of start index. + * @param length The run of length, if start and length are set to 0, then get all of the current run. + * @return Run of glyph indices array. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, int64_t start, int64_t length); + +/** + * @brief Gets the run glyph indices by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array the run glyph indices array. + * @param index The run of glyph index. + * @return Run of glyph indices element. + * @since 14 + * @version 1.0 + */ +uint64_t OH_Drawing_GetRunStringIndicesElement(OH_Drawing_Array* stringIndices, size_t index); + +/** + * @brief Releases the memory run glyph indices array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param stringIndices glyph indices the pointer. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* stringIndices); + +/** + * @brief Gets the range run glyph location and length. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param location The run of glyph location. + * @param length The run of glyph length. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint64_t* location, uint64_t* length); + +/** + * @brief Gets the run typographic bound. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param ascent The run of ascent. + * @param descent The run of descent. + * @param leading The run of leading. + * @return run typographic width. + * @since 14 + * @version 1.0 + */ +float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, float* descent, float* leading); + +/** + * @brief Paints text on the canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param x Indicates the x coordinate. + * @param y Indicates the y coordinate. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_RunPaint(OH_Drawing_Canvas* canvas, OH_Drawing_Run* run, double x, double y); + +/** + * @brief Gets the run image bound. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @return OH_Drawing_Rect The run image bounds. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run); + + /** + * @brief Releases the memory run image bounds pointer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Rect Run image bounds pointer. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyRunImageBounds(OH_Drawing_Rect* rect); + +/** + * @brief Gets the range glyph identifier for each character. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param start The run of start index. + * @param length The run of length, if start and length are set to 0, then get all of the current run. + * @return Run of glyph array. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetRunGlyphs(OH_Drawing_Run* run, int64_t start, int64_t length); + +/** + * @brief Gets the glyph identifier by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param glyphs The run of glyph array. + * @param index The run of glyph index. + * @return Run of glyph element. + * @since 14 + * @version 1.0 + */ +uint16_t OH_Drawing_GetRunGlyphsElement(OH_Drawing_Array* glyphs, size_t index); + +/** + * @brief Releases the memory run glyph array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param glyphs The run of glyph array. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs); + +/** + * @brief Gets the range glyph position array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param start The run of start index. + * @param length The run of length, if start and length are set to 0, then get all of the current run. + * @return Run of position array. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, int64_t start, int64_t length); + +/** + * @brief Gets the glyph position by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Array The run of position array. + * @param index The run of glyph index. + * @return Run of glyph position pointer. + * @since 14 + * @version 1.0 + */ +OH_Drawing_Point* OH_Drawing_GetRunPositionsElement(OH_Drawing_Array* positions, size_t index); + +/** + * @brief Releases the memory run of position array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param positions The run of position array. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions); + +/** + * @brief Gets the number of glyph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @return The number of glyph. + * @since 14 + * @version 1.0 + */ +uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run); +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // C_INCLUDE_DRAWING_TEXT_RUN_H diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index d821c3855..977062e81 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -45,6 +45,7 @@ #include "drawing_color.h" #include "drawing_font.h" #include "drawing_text_declaration.h" +#include "drawing_text_font_descriptor.h" #include "drawing_types.h" #include "stdint.h" @@ -412,35 +413,6 @@ typedef struct OH_Drawing_FontConfigInfo { OH_Drawing_FontFallbackGroup* fallbackGroupSet; } OH_Drawing_FontConfigInfo; -/** - * @brief Describes the font information. - * - * @since 12 - * @version 1.0 - */ -typedef struct OH_Drawing_FontDescriptor { - /** The file path of System font */ - char* path; - /** A name that uniquely identifies the font */ - char* postScriptName; - /** The name of System font */ - char* fullName; - /** The family of System font */ - char* fontFamily; - /** The subfont family of the system font */ - char* fontSubfamily; - /** The weight of System font */ - int weight; - /** The width of System font */ - int width; - /** Whether the system font is tilted */ - int italic; - /** Whether the system font is compact */ - bool monoSpace; - /** whether symbolic fonts are supported */ - bool symbolic; -} OH_Drawing_FontDescriptor; - /** * @brief The metrics of line. * @@ -734,6 +706,29 @@ void OH_Drawing_SetTextStyleBaseLine(OH_Drawing_TextStyle*, int /* OH_Drawing_Te */ void OH_Drawing_SetTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */); +/** + * @brief Add the text decoration. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param int Indicates the text decoration to add. For details, see the enum OH_Drawing_TextDecoration. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_AddTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */); + +/** + * @brief Remove the text decoration. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextStyle Indicates the pointer to an OH_Drawing_TextStyle object. + * @param int Indicates the text decoration to remove, shoud be match existing text decorations. + * For details, see the enum OH_Drawing_TextDecoration. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_RemoveTextStyleDecoration(OH_Drawing_TextStyle*, int /* OH_Drawing_TextDecoration */); + /** * @brief Sets the color for the text decoration. * @@ -2753,6 +2748,76 @@ 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_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextAlign Indicates enumerates text tab alignment modes. TAB alignment, Support left alignment + * right alignment center alignment, other enumeration values are left alignment effect. + * @param float Indicates location if text tab. + * @return Returns the pointer to the OH_Drawing_TextTab object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_TextTab* OH_Drawing_CreateTextTab(OH_Drawing_TextAlign alignment, float location); + +/** + * @brief Releases the memory occupied by an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_DestroyTextTab(OH_Drawing_TextTab*); + +/** + * @brief Get align of an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @return Returns align of an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +OH_Drawing_TextAlign OH_Drawing_GetTextTabAlign(OH_Drawing_TextTab*); + +/** + * @brief Get location of an OH_Drawing_TextTab object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @return Returns location of an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +float OH_Drawing_GetTextTabLocation(OH_Drawing_TextTab*); + +/** + * @brief Sets the text tab of OH_Drawing_TypographyStyle object. + * TAB alignment does not take effect when text alignment is also set. Or when the TAB's location property + * is less than or equal to 0. When the TAB is not set, it is the default space effect, and all tabs in the paragraph + * after the setting are aligned according to this tab effect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. + * @since 14 + * @version 1.0 + */ +void OH_Drawing_SetTypographyTextTab(OH_Drawing_TypographyStyle*, OH_Drawing_TextTab* TextTab); + +/** + * @brief Get DrawingArray size. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param drawingArray Indicates the pointer to the array object OH_Drawing_Array. + * @return Size of array. + * @since 14 + * @version 1.0 + */ +size_t OH_Drawing_GetDrawingArraySize(OH_Drawing_Array* drawingArray); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index e040acdfc..22f860ebb 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -471,6 +471,19 @@ typedef struct { double leftBottomRadius; } OH_Drawing_RectStyle_Info; +/** + * @brief Defines the string information struct. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /** A pointer to a byte string containing UTF-16BE(Big Endian) encoded entities */ + uint8_t* strData; + /** The length of `strData` in bytes */ + uint32_t strLen; +} OH_Drawing_String; + /** * @brief Enumerates text encoding types. * @since 12 @@ -518,6 +531,14 @@ typedef struct OH_Drawing_RecordCmdUtils OH_Drawing_RecordCmdUtils; * @version 1.0 */ typedef struct OH_Drawing_RecordCmd OH_Drawing_RecordCmd; + +/** + * @brief Defines an array object, which is used to store multiple NDK object. + * + * @since 14 + * @version 1.0 + */ +typedef struct OH_Drawing_Array OH_Drawing_Array; #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 9c5b0d269..264d710ff 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -615,6 +615,14 @@ { "name": "OH_Drawing_SetTextStyleFontWeight" }, { "name": "OH_Drawing_SetTextStyleBaseLine" }, { "name": "OH_Drawing_SetTextStyleDecoration" }, + { + "first_introduced": "14", + "name": "OH_Drawing_AddTextStyleDecoration" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RemoveTextStyleDecoration" + }, { "name": "OH_Drawing_SetTextStyleDecorationColor" }, { "name": "OH_Drawing_SetTextStyleFontHeight" }, { "name": "OH_Drawing_SetTextStyleFontFamilies" }, @@ -902,6 +910,14 @@ "first_introduced": "12", "name": "OH_Drawing_DestroyFontDescriptor" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatchFontDescriptors" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_DestroyFontDescriptors" + }, { "first_introduced": "12", "name": "OH_Drawing_CreateFontParser" @@ -910,6 +926,22 @@ "first_introduced": "12", "name": "OH_Drawing_DestroyFontParser" }, + { + "first_introduced": "14", + "name": "OH_Drawing_GetFontDescriptorByFullName" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_GetSystemFontFullNamesByType" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_GetSystemFontFullNamesElement" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_DestroySystemFontFullNames" + }, { "first_introduced": "12", "name": "OH_Drawing_FontParserGetSystemFontList" @@ -1465,5 +1497,205 @@ { "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" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_FontGetBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_FontGetPathForGlyph" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectCreateArray" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectGetArraySize" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectGetArrayElement" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RectDestroyArray" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_CreateTextTab" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyTextTab" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetTextTabAlign" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetTextTabLocation" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_SetTypographyTextTab" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_FontGetTextPath" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetDrawingArraySize" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TypographyGetTextLines" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyTextLines" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyTextLine" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetTextLinesIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetGlyphCount" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetTextRange" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetGlyphRuns" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRuns" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunsIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLinePaint" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineCreateTruncatedLine" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetTypographicBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetImageBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetTrailingSpaceWidth" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetStringIndexForPosition" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetOffsetForStringIndex" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineEnumerateCaretOffsets" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_TextLineGetAlignmentOffset" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunStringIndices" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunStringIndicesElement" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunStringIndices" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunStringRange" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunTypographicBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_RunPaint" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunImageBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunImageBounds" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunGlyphs" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunGlyphsElement" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunGlyphs" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunPositions" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunPositionsElement" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_DestroyRunPositions" + }, + { + "first_introduced": "14", + "name":"OH_Drawing_GetRunGlyphCount" } ] \ No newline at end of file -- Gitee From da9c47f7f79018fce6b7bd242d1ce8dde2c1cfe9 Mon Sep 17 00:00:00 2001 From: changleipeng Date: Wed, 18 Sep 2024 16:50:57 +0800 Subject: [PATCH 2/2] restore OH_Drawing_FontDescriptor position Signed-off-by: changleipeng --- .../kit_sub_system/c_file_kit_sub_system.json | 15 --- .../graphic_2d/native_drawing/drawing_font.h | 7 +- .../graphic_2d/native_drawing/drawing_rect.h | 1 - .../drawing_text_font_descriptor.h | 102 +++++------------- .../native_drawing/drawing_text_line.h | 56 +++------- .../drawing_text_lineTypography.h | 11 +- .../native_drawing/drawing_text_run.h | 75 ++++++------- .../native_drawing/drawing_text_typography.h | 46 ++++++-- .../native_drawing/libnative_drawing.ndk.json | 18 ++-- 9 files changed, 120 insertions(+), 211 deletions(-) diff --git a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json index 44c8cffcf..668e349de 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json +++ b/build-tools/capi_parser/src/coreImpl/parser/kit_sub_system/c_file_kit_sub_system.json @@ -269,21 +269,6 @@ "kitName": "ArkGraphicsD", "subSystem": "图形图像" }, - { - "filePath": "graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h", - "kitName": "ArkGraphicsD", - "subSystem": "图形图像" - }, - { - "filePath": "graphic/graphic_2d/native_drawing/drawing_text_line.h", - "kitName": "ArkGraphicsD", - "subSystem": "图形图像" - }, - { - "filePath": "graphic/graphic_2d/native_drawing/drawing_text_run.h", - "kitName": "ArkGraphicsD", - "subSystem": "图形图像" - }, { "filePath": "graphic/graphic_2d/native_drawing/drawing_text_typography.h", "kitName": "ArkGraphicsD", diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 0f0428395..ca4eac990 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -539,15 +539,14 @@ OH_Drawing_ErrorCode OH_Drawing_FontGetPathForGlyph(const OH_Drawing_Font* font, * @param font Indicates the pointer to an OH_Drawing_Font object. * @param text Indicates the character storage encoded with text encoding. * @param byteLength Indicates the text length in bytes. - * @param encoding Indicates the text encoding. - * @param x Indicates x coordinates of the text. + * @param encoding OH_Drawing_TextEncoding Indicates the text encoding. + * @param x Indicates x coordinates of the text. * @param y Indicates y coordinates of the text. - * @param path The path object, returned to the caller. + * @param path OH_Drawing_Path The path object, returned to the caller. * @return Returns the error code. * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of font, text or path is nullptr. * @since 14 - * @version 1.0 */ OH_Drawing_ErrorCode OH_Drawing_FontGetTextPath(const OH_Drawing_Font* font, const void* text, size_t byteLength, OH_Drawing_TextEncoding encoding, float x, float y, OH_Drawing_Path* path); diff --git a/graphic/graphic_2d/native_drawing/drawing_rect.h b/graphic/graphic_2d/native_drawing/drawing_rect.h index 02c134f2b..6ea9ca992 100644 --- a/graphic/graphic_2d/native_drawing/drawing_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_rect.h @@ -255,7 +255,6 @@ OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, si * or index is valid. * @since 14 * @version 1.0 - * @note Return nullptr if OH_Drawing_Array or index invalid. */ OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index, OH_Drawing_Rect** rect); diff --git a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h index 270e7c602..e6c262107 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -13,9 +13,6 @@ * limitations under the License. */ -#ifndef C_INCLUDE_DRAWING_TEXT_FONT_DESCRIPTOR_H -#define C_INCLUDE_DRAWING_TEXT_FONT_DESCRIPTOR_H - /** * @addtogroup Drawing * @{ @@ -24,7 +21,7 @@ * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * - * @since 8 + * @since 14 * @version 1.0 */ @@ -36,34 +33,23 @@ * @kit ArkGraphics2D * @library libnative_drawing.so * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @since 8 + * @since 14 * @version 1.0 */ -#include "drawing_types.h" +#ifndef DRAWING_TEXT_FONT_DESCRIPTOR_H +#define DRAWING_TEXT_FONT_DESCRIPTOR_H + +#include "drawing_text_typography.h" #ifdef __cplusplus extern "C" { #endif -/** - * @brief Type style flag. - * - * @since 14 - * @version 1.0 - */ -typedef enum { - /** Italic font */ - ITALIC = 1 << 0, - /** Bold font */ - BOLD = 1 << 1, -} OH_Drawing_FontTypeStyle; - /** * @brief An enumeration of system font types. * * @since 14 - * @version 1.0 */ typedef enum { /** All font types */ @@ -77,52 +63,20 @@ typedef enum { } OH_Drawing_SystemFontType; /** - * @brief Describes the font information. - * - * @since 12 - * @version 1.0 - */ -typedef struct OH_Drawing_FontDescriptor { - /** The file path of System font */ - char* path; - /** A name that uniquely identifies the font */ - char* postScriptName; - /** The name of System font */ - char* fullName; - /** The family of System font */ - char* fontFamily; - /** The subfont family of the system font */ - char* fontSubfamily; - /** The weight of System font */ - int weight; - /** The width of System font */ - int width; - /** Whether the system font is tilted */ - int italic; - /** Whether the system font is compact */ - bool monoSpace; - /** whether symbolic fonts are supported */ - bool symbolic; - /** Font size */ - size_t size; - /** Font style flag, from OH_Drawing_FontTypeStyle */ - int typeStyle; -} OH_Drawing_FontDescriptor; - -/** - * @brief Obtain all system font descriptive symbols that match the specified font descriptor. Where the 'path' and - * 'size' fields are not considered as valid matching values, It takes effect when the remaining fields are not + * @brief Obtain all system font descriptive symbols that match the specified font descriptor. Where the 'path' + * fields are not considered as valid matching values, It takes effect when the remaining fields are not * default values, If all the fields of the parameters OH_Drawing_FontDescriptor are default, obtain all system * font descriptors. If the match fails, return nullptr. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_FontDescriptor The pointer to the OH_Drawing_FontDescriptor object. It is recommended to - * use OH_Drawing_CreateFontDescriptor to obtain a valid OH_Drawing_FontDescriptor instance. If you create your own - * OH_Drawing_FontDescriptor object, ensure that fields not intended for matching are set to their default values. + * use OH_Drawing_CreateFontDescriptor to obtain a valid OH_Drawing_FontDescriptor instance. + * If you create your own OH_Drawing_FontDescriptor object, ensure that fields not intended for matching are + * set to their default values. * @param size_t Indicates the count of obtained OH_Drawing_FontDescriptor. - * @return Returns an array of OH_Drawing_FontDescriptor. + * @return Returns an array of OH_Drawing_FontDescriptor. Released through the + * OH_Drawing_DestroyFontDescriptors interface after use. * @since 14 - * @version 1.0 */ OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescriptor*, size_t*); @@ -130,38 +84,36 @@ OH_Drawing_FontDescriptor* OH_Drawing_MatchFontDescriptors(OH_Drawing_FontDescri * @brief Releases the OH_Drawing_FontDescriptor array. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_FontDescriptor Pointer to OH_Drawing_FontDescriptor array. - * @param size_t Represents the number of members of the OH_Drawing_FontDescriptor array. + * @param OH_Drawing_FontDescriptor OH_Drawing_FontDescriptor object array. + * @param size_t Represents the number of members of the OH_Drawing_FontDescriptor array. * @since 14 - * @version 1.0 */ void OH_Drawing_DestroyFontDescriptors(OH_Drawing_FontDescriptor*, size_t); /** - * @brief Get the OH_Drawing_FontDescriptor object by the full name of the font, supporting generic fonts, - * stylish fonts, and installed fonts. + * @brief Get the OH_Drawing_FontDescriptor object by the font full name and the font type, supporting generic + * fonts, stylish fonts, and installed fonts. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_String* Indicates the full name object OH_Drawing_String. + * @param OH_Drawing_String Indicates the full name object OH_Drawing_String. + * @param OH_Drawing_SystemFontType Indicates enumerates of system font type object OH_Drawing_SystemFontType. * @return Returns the pointer to a font descriptor object OH_Drawing_FontDescriptor. * @since 14 - * @version 1.0 */ -OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String*); +OH_Drawing_FontDescriptor* OH_Drawing_GetFontDescriptorByFullName(const OH_Drawing_String*, OH_Drawing_SystemFontType); /** - * @brief Obtain the corresponding font full name list by the font type. + * @brief Obtain the corresponding font full name array by the font type. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_SystemFontType Indicates enumerates of system font type. + * @param OH_Drawing_SystemFontType Indicates enumerates of system font type object OH_Drawing_SystemFontType. * @return Returns the pointer to full name array object OH_Drawing_Array. * @since 14 - * @version 1.0 */ OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontType); /** - * @brief Get the specified full name object OH_Drawing_String by index from the + * @brief Get the specified full name object OH_Drawing_String by index from the * OH_Drawing_Array object. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing @@ -169,17 +121,15 @@ OH_Drawing_Array* OH_Drawing_GetSystemFontFullNamesByType(OH_Drawing_SystemFontT * @param size_t The index of full name. * @return Returns a full name object OH_Drawing_String. * @since 14 - * @version 1.0 */ -const OH_Drawing_String* OH_Drawing_GetSystemFontFullNamesElement(OH_Drawing_Array*, size_t); +const OH_Drawing_String* OH_Drawing_GetSystemFontFullNameByIndex(OH_Drawing_Array*, size_t); /** - * @brief Releases the memory occupied by a list of system font names. + * @brief Releases the memory occupied by an array of font full names. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Array Indicates an array of full name. + * @param OH_Drawing_Array Indicates an array of full name object OH_Drawing_Array. * @since 14 - * @version 1.0 */ void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array*); diff --git a/graphic/graphic_2d/native_drawing/drawing_text_line.h b/graphic/graphic_2d/native_drawing/drawing_text_line.h index e83eead09..196907ed5 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_line.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_line.h @@ -13,9 +13,6 @@ * limitations under the License. */ -#ifndef C_INCLUDE_DRAWING_TEXT_LINE_H -#define C_INCLUDE_DRAWING_TEXT_LINE_H - /** * @addtogroup Drawing * @{ @@ -37,6 +34,9 @@ * @version 1.0 */ +#ifndef C_INCLUDE_DRAWING_TEXT_LINE_H +#define C_INCLUDE_DRAWING_TEXT_LINE_H + #include "drawing_text_declaration.h" #include "drawing_types.h" @@ -48,10 +48,9 @@ extern "C" { * @brief Get text line information. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Typography Indicates the pointer to a typography object OH_Drawing_Typography. + * @param typography Indicates the pointer to a typography object OH_Drawing_Typography. * @return Indicates the pointer to a text line array object OH_Drawing_Array. * @since 14 - * @version 1.0 */ OH_Drawing_Array* OH_Drawing_TypographyGetTextLines(OH_Drawing_Typography* typography); @@ -80,12 +79,11 @@ void OH_Drawing_DestroyTextLine(OH_Drawing_TextLine* line); * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param lines Indicates the pointer to the text line array object OH_Drawing_Array. - * @param index text line object index. + * @param index The text line object index. * @return Indicates the pointer to a text line object OH_Drawing_TextLine. * @since 14 - * @version 1.0 */ -OH_Drawing_TextLine* OH_Drawing_GetTextLinesIndex(OH_Drawing_Array* lines, size_t index); +OH_Drawing_TextLine* OH_Drawing_GetTextLineByIndex(OH_Drawing_Array* lines, size_t index); /** * @brief Get the count of glyphs. @@ -136,19 +134,18 @@ void OH_Drawing_DestroyRuns(OH_Drawing_Array* runs); * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param runs Indicates the pointer to the run array object OH_Drawing_Array. - * @param index run object index. + * @param index The run object index. * @return Indicates the pointer to a run object OH_Drawing_Run. * @since 14 - * @version 1.0 */ -OH_Drawing_Run* OH_Drawing_GetRunsIndex(OH_Drawing_Array* runs, size_t index); +OH_Drawing_Run* OH_Drawing_GetRunByIndex(OH_Drawing_Array* runs, size_t index); /** * @brief Paint the range of text line. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param line Indicates the pointer to an OH_Drawing_TextLine object. - * @param canvas Draw the text line on the canvas. + * @param canvas Indicates the pointer to an OH_Drawing_Canvas object. * @param x Represents the X-axis position on the canvas. * @param y Represents the Y-axis position on the canvas. * @since 14 @@ -214,10 +211,9 @@ double OH_Drawing_TextLineGetTrailingSpaceWidth(OH_Drawing_TextLine* line); * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param line Indicates the pointer to an OH_Drawing_TextLine object. - * @param point The given position. + * @param point Indicates the pointer to an OH_Drawing_Point object. * @return Returns the string index for a given position. * @since 14 - * @version 1.0 */ int32_t OH_Drawing_TextLineGetStringIndexForPosition(OH_Drawing_TextLine* line, OH_Drawing_Point* point); @@ -227,38 +223,10 @@ int32_t OH_Drawing_TextLineGetStringIndexForPosition(OH_Drawing_TextLine* line, * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param line Indicates the pointer to an OH_Drawing_TextLine object. * @param index The given string index. - * @param secondOffset Indicates the pointer to the offset of compound character, not supported. - * @return Returns the offset info for a given string index. - * @since 14 - * @version 1.0 - */ -double OH_Drawing_TextLineGetOffsetForStringIndex(OH_Drawing_TextLine* line, int32_t index, double* secondOffset); - -/** - * @brief User-defined callback functions for using offsets and indexes. - * - * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param offset Character offset is traversed as an argument to the callback function. - * @param index Character index is traversed as an argument to the callback function. - * @param leadingEdge Whether the current offset is at the character front, as an argument to the callback function. - * @return The return value of the user-defined callback function. - * If false is returned, the traversal continues. - * If true is returned, the traversal stops. + * @return Returns the offset for a given string index. * @since 14 - * @version 1.0 - */ -typedef bool (*CustomCallback)(double offset, int32_t index, bool leadingEdge); - -/** - * @brief Enumerate caret offset and index in text lines. - * - * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param line Indicates the pointer to an OH_Drawing_TextLine object. - * @param callback User-defined callback functions, see CustomCallback. - * @since 14 - * @version 1.0 */ -void OH_Drawing_TextLineEnumerateCaretOffsets(OH_Drawing_TextLine* line, CustomCallback callback); +double OH_Drawing_TextLineGetOffsetForStringIndex(OH_Drawing_TextLine* line, int32_t index); /** * @brief Gets the text offset based on the given alignment factor and alignment width. diff --git a/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h b/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h index f480cd643..6d20d529b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h @@ -13,9 +13,6 @@ * limitations under the License. */ -#ifndef C_INCLUDE_DRAWING_TEXT_LINETYPOGRAPHY_H -#define C_INCLUDE_DRAWING_TEXT_LINETYPOGRAPHY_H - /** * @addtogroup Drawing * @{ @@ -40,7 +37,9 @@ * @version 1.0 */ -#include "cstddef" +#ifndef DRAWING_TEXT_LINETYPOGRAPHY_H +#define DRAWING_TEXT_LINETYPOGRAPHY_H + #include "drawing_text_declaration.h" #ifdef __cplusplus @@ -54,7 +53,6 @@ extern "C" { * @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 - * @version 1.0 */ OH_Drawing_LineTypography* OH_Drawing_CreateLineTypography(OH_Drawing_TypographyCreate* handler); @@ -64,7 +62,6 @@ OH_Drawing_LineTypography* OH_Drawing_CreateLineTypography(OH_Drawing_Typography * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_LineTypography Indicates the pointer to an OH_Drawing_LineTypography object. * @since 14 - * @version 1.0 */ void OH_Drawing_DestroyLineTypography(OH_Drawing_LineTypography* lineTypography); @@ -77,7 +74,6 @@ void OH_Drawing_DestroyLineTypography(OH_Drawing_LineTypography* lineTypography) * @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 - * @version 1.0 */ size_t OH_Drawing_LineTypographyGetLineBreak(OH_Drawing_LineTypography* lineTypography, size_t startIndex, double width); @@ -91,7 +87,6 @@ size_t OH_Drawing_LineTypographyGetLineBreak(OH_Drawing_LineTypography* lineTypo * @param count Indicates the characters count of the text range. * @return Returns the pointer to the OH_Drawing_TextLine object created. * @since 14 - * @version 1.0 */ OH_Drawing_TextLine* OH_Drawing_LineTypographyCreateLine(OH_Drawing_LineTypography* lineTypography, size_t startIndex, size_t count); diff --git a/graphic/graphic_2d/native_drawing/drawing_text_run.h b/graphic/graphic_2d/native_drawing/drawing_text_run.h index 28949dc42..b71a197dd 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_run.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_run.h @@ -13,9 +13,6 @@ * limitations under the License. */ -#ifndef C_INCLUDE_DRAWING_TEXT_RUN_H -#define C_INCLUDE_DRAWING_TEXT_RUN_H - /** * @addtogroup Drawing * @{ @@ -37,6 +34,9 @@ * @version 1.0 */ +#ifndef C_INCLUDE_DRAWING_TEXT_RUN_H +#define C_INCLUDE_DRAWING_TEXT_RUN_H + #include "drawing_text_declaration.h" #include "drawing_types.h" @@ -47,12 +47,11 @@ extern "C" { * @brief Gets the run glyph indices ,the offset of the index relative to the entire paragraph. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param run Indicates the pointer to an OH_Drawing_Run object. * @param start The run of start index. * @param length The run of length, if start and length are set to 0, then get all of the current run. - * @return Run of glyph indices array. + * @return Run of glyph indices array object OH_Drawing_Array. * @since 14 - * @version 1.0 */ OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, int64_t start, int64_t length); @@ -60,21 +59,19 @@ OH_Drawing_Array* OH_Drawing_GetRunStringIndices(OH_Drawing_Run* run, int64_t st * @brief Gets the run glyph indices by index. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Array the run glyph indices array. + * @param stringIndices the run glyph indices array object OH_Drawing_Array. * @param index The run of glyph index. * @return Run of glyph indices element. * @since 14 - * @version 1.0 */ -uint64_t OH_Drawing_GetRunStringIndicesElement(OH_Drawing_Array* stringIndices, size_t index); +uint64_t OH_Drawing_GetRunStringIndicesByIndex(OH_Drawing_Array* stringIndices, size_t index); /** * @brief Releases the memory run glyph indices array. - * + * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param stringIndices glyph indices the pointer. + * @param stringIndices glyph indices array object OH_Drawing_Array. * @since 14 - * @version 1.0 */ void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* stringIndices); @@ -82,11 +79,10 @@ void OH_Drawing_DestroyRunStringIndices(OH_Drawing_Array* stringIndices); * @brief Gets the range run glyph location and length. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param run Indicates the pointer to an OH_Drawing_Run object. * @param location The run of glyph location. * @param length The run of glyph length. * @since 14 - * @version 1.0 */ void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint64_t* location, uint64_t* length); @@ -94,13 +90,12 @@ void OH_Drawing_GetRunStringRange(OH_Drawing_Run* run, uint64_t* location, uint6 * @brief Gets the run typographic bound. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param run Indicates the pointer to an OH_Drawing_Run object. * @param ascent The run of ascent. * @param descent The run of descent. * @param leading The run of leading. * @return run typographic width. * @since 14 - * @version 1.0 */ float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, float* descent, float* leading); @@ -108,12 +103,11 @@ float OH_Drawing_GetRunTypographicBounds(OH_Drawing_Run* run, float* ascent, flo * @brief Paints text on the canvas. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param run Indicates the pointer to an OH_Drawing_Run object. * @param x Indicates the x coordinate. * @param y Indicates the y coordinate. * @since 14 - * @version 1.0 */ void OH_Drawing_RunPaint(OH_Drawing_Canvas* canvas, OH_Drawing_Run* run, double x, double y); @@ -121,10 +115,9 @@ void OH_Drawing_RunPaint(OH_Drawing_Canvas* canvas, OH_Drawing_Run* run, double * @brief Gets the run image bound. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. - * @return OH_Drawing_Rect The run image bounds. + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @return The run image bounds to an OH_Drawing_Rect object. * @since 14 - * @version 1.0 */ OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run); @@ -132,22 +125,20 @@ OH_Drawing_Rect* OH_Drawing_GetRunImageBounds(OH_Drawing_Run* run); * @brief Releases the memory run image bounds pointer. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Rect Run image bounds pointer. + * @param rect Run image bounds to an OH_Drawing_Rect object. * @since 14 - * @version 1.0 */ void OH_Drawing_DestroyRunImageBounds(OH_Drawing_Rect* rect); /** * @brief Gets the range glyph identifier for each character. - * + * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param run Indicates the pointer to an OH_Drawing_Run object. * @param start The run of start index. * @param length The run of length, if start and length are set to 0, then get all of the current run. - * @return Run of glyph array. + * @return Run of glyph array object OH_Drawing_ArrayOH_Drawing_Array. * @param index The run of glyph index. * @return Run of glyph element. * @since 14 * @version 1.0 */ -uint16_t OH_Drawing_GetRunGlyphsElement(OH_Drawing_Array* glyphs, size_t index); +uint16_t OH_Drawing_GetRunGlyphsByIndex(OH_Drawing_Array* glyphs, size_t index); /** * @brief Releases the memory run glyph array. - * + * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param glyphs The run of glyph array. + * @param glyphs The run of glyph array object OH_Drawing_Array. * @since 14 - * @version 1.0 */ void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs); @@ -177,12 +167,11 @@ void OH_Drawing_DestroyRunGlyphs(OH_Drawing_Array* glyphs); * @brief Gets the range glyph position array. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param run Indicates the pointer to an OH_Drawing_Run object. * @param start The run of start index. * @param length The run of length, if start and length are set to 0, then get all of the current run. - * @return Run of position array. + * @return Run of position array object OH_Drawing_Array. * @since 14 - * @version 1.0 */ OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, int64_t start, int64_t length); @@ -190,21 +179,20 @@ OH_Drawing_Array* OH_Drawing_GetRunPositions(OH_Drawing_Run* run, int64_t start, * @brief Gets the glyph position by index. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Array The run of position array. + * @param positions The run of position array object OH_Drawing_Array. * @param index The run of glyph index. - * @return Run of glyph position pointer. + * @return Run of glyph position pointer to an OH_Drawing_Point object. * @since 14 * @version 1.0 */ -OH_Drawing_Point* OH_Drawing_GetRunPositionsElement(OH_Drawing_Array* positions, size_t index); +OH_Drawing_Point* OH_Drawing_GetRunPositionsByIndex(OH_Drawing_Array* positions, size_t index); /** * @brief Releases the memory run of position array. - * + * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param positions The run of position array. + * @param positions The run of position array object OH_Drawing_Array. * @since 14 - * @version 1.0 */ void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions); @@ -212,10 +200,9 @@ void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions); * @brief Gets the number of glyph. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param OH_Drawing_Run Indicates the pointer to an OH_Drawing_Run object. + * @param run Indicates the pointer to an OH_Drawing_Run object. * @return The number of glyph. * @since 14 - * @version 1.0 */ uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run); #ifdef __cplusplus diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 977062e81..28ffa8f5a 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -45,7 +45,6 @@ #include "drawing_color.h" #include "drawing_font.h" #include "drawing_text_declaration.h" -#include "drawing_text_font_descriptor.h" #include "drawing_types.h" #include "stdint.h" @@ -413,6 +412,35 @@ typedef struct OH_Drawing_FontConfigInfo { OH_Drawing_FontFallbackGroup* fallbackGroupSet; } OH_Drawing_FontConfigInfo; +/** + * @brief Describes the font information. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontDescriptor { + /** The file path of System font */ + char* path; + /** A name that uniquely identifies the font */ + char* postScriptName; + /** The name of System font */ + char* fullName; + /** The family of System font */ + char* fontFamily; + /** The subfont family of the system font */ + char* fontSubfamily; + /** The weight of System font */ + int weight; + /** The width of System font */ + int width; + /** Whether the system font is tilted */ + int italic; + /** Whether the system font is compact */ + bool monoSpace; + /** whether symbolic fonts are supported */ + bool symbolic; +} OH_Drawing_FontDescriptor; + /** * @brief The metrics of line. * @@ -2754,8 +2782,10 @@ void OH_Drawing_SetTextShadow(OH_Drawing_TextShadow* shadow, uint32_t color, OH_ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_TextAlign Indicates enumerates text tab alignment modes. TAB alignment, Support left alignment * right alignment center alignment, other enumeration values are left alignment effect. - * @param float Indicates location if text tab. - * @return Returns the pointer to the OH_Drawing_TextTab object created. + * @param float Indicates location of text tab. + * @return Returns the pointer to the OH_Drawing_TextTab object created. If the object returns NULL, + * the creation failed. The possible cause of the failure is that the application address space is used up. + * As a result, space cannot be allocated. * @since 14 * @version 1.0 */ @@ -2772,7 +2802,7 @@ OH_Drawing_TextTab* OH_Drawing_CreateTextTab(OH_Drawing_TextAlign alignment, flo void OH_Drawing_DestroyTextTab(OH_Drawing_TextTab*); /** - * @brief Get align of an OH_Drawing_TextTab object. + * @brief Get alignment of an OH_Drawing_TextTab object. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_TextTab Indicates the pointer to an OH_Drawing_TextTab object. @@ -2780,7 +2810,7 @@ void OH_Drawing_DestroyTextTab(OH_Drawing_TextTab*); * @since 14 * @version 1.0 */ -OH_Drawing_TextAlign OH_Drawing_GetTextTabAlign(OH_Drawing_TextTab*); +OH_Drawing_TextAlign OH_Drawing_GetTextTabAlignment(OH_Drawing_TextTab*); /** * @brief Get location of an OH_Drawing_TextTab object. @@ -2795,9 +2825,9 @@ float OH_Drawing_GetTextTabLocation(OH_Drawing_TextTab*); /** * @brief Sets the text tab of OH_Drawing_TypographyStyle object. - * TAB alignment does not take effect when text alignment is also set. Or when the TAB's location property - * is less than or equal to 0. When the TAB is not set, it is the default space effect, and all tabs in the paragraph - * after the setting are aligned according to this tab effect. + * Tab alignment does not take effect when text alignment is also set, Or when the ellipsis style is configured. + * When the tab is not set or the tab's location property is less than or equal to 0, it is the default space effect. + * And all tabs in the paragraph after the setting are aligned according to this tab effect. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_TypographyStyle Indicates the pointer to an OH_Drawing_TypographyStyle object. diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 264d710ff..870a68817 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -936,7 +936,7 @@ }, { "first_introduced": "14", - "name": "OH_Drawing_GetSystemFontFullNamesElement" + "name": "OH_Drawing_GetSystemFontFullNameByIndex" }, { "first_introduced": "14", @@ -1548,7 +1548,7 @@ }, { "first_introduced": "14", - "name":"OH_Drawing_GetTextTabAlign" + "name":"OH_Drawing_GetTextTabAlignment" }, { "first_introduced": "14", @@ -1580,7 +1580,7 @@ }, { "first_introduced": "14", - "name":"OH_Drawing_GetTextLinesIndex" + "name":"OH_Drawing_GetTextLineByIndex" }, { "first_introduced": "14", @@ -1600,7 +1600,7 @@ }, { "first_introduced": "14", - "name":"OH_Drawing_GetRunsIndex" + "name":"OH_Drawing_GetRunByIndex" }, { "first_introduced": "14", @@ -1630,10 +1630,6 @@ "first_introduced": "14", "name":"OH_Drawing_TextLineGetOffsetForStringIndex" }, - { - "first_introduced": "14", - "name":"OH_Drawing_TextLineEnumerateCaretOffsets" - }, { "first_introduced": "14", "name":"OH_Drawing_TextLineGetAlignmentOffset" @@ -1644,7 +1640,7 @@ }, { "first_introduced": "14", - "name":"OH_Drawing_GetRunStringIndicesElement" + "name":"OH_Drawing_GetRunStringIndicesByIndex" }, { "first_introduced": "14", @@ -1676,7 +1672,7 @@ }, { "first_introduced": "14", - "name":"OH_Drawing_GetRunGlyphsElement" + "name":"OH_Drawing_GetRunGlyphsByIndex" }, { "first_introduced": "14", @@ -1688,7 +1684,7 @@ }, { "first_introduced": "14", - "name":"OH_Drawing_GetRunPositionsElement" + "name":"OH_Drawing_GetRunPositionsByIndex" }, { "first_introduced": "14", -- Gitee