From 9ad1b27f6947418d0eacc7800ca6b565817b0fe3 Mon Sep 17 00:00:00 2001 From: liufei Date: Tue, 9 Sep 2025 20:28:27 +0800 Subject: [PATCH 01/12] feat(graphic): add font full descriptor parsing functionality - Add new functions to parse font full descriptors from a memory stream - Implement methods to retrieve font descriptor attributes (int, bool, string) - Update header file with new function declarations and necessary includes Signed-off-by: liufei --- .../drawing_text_font_descriptor.h | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) 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 e89a96b06dc..c0b0dc6e3e1 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -40,6 +40,7 @@ #ifndef DRAWING_TEXT_FONT_DESCRIPTOR_H #define DRAWING_TEXT_FONT_DESCRIPTOR_H +#include "drawing_memory_stream.h" #include "drawing_text_typography.h" #ifdef __cplusplus @@ -139,6 +140,83 @@ const OH_Drawing_String* OH_Drawing_GetSystemFontFullNameByIndex(OH_Drawing_Arra */ void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array* fullNameArray); +/** + * @brief Obtains an array of font full descriptors from a memory stream. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param stream Indicates the pointer to the memory stream OH_Drawing_MemoryStream containing font data. + * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. + * Returns NULL if parsing fails or the stream contains invalid data. + * @since 21 + */ +OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(OH_Drawing_MemoryStream* stream); + + +/** + * @brief Retrieves a font full descriptor from an array by index. + * + * This function accesses a specific font descriptor within an array of font full descriptors + * obtained from OH_Drawing_GetFontFullDescriptorsFromStream. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param fullNameArray Pointer to the array of font descriptors OH_Drawing_Array. + * @param index Zero-based index position of the descriptor to retrieve. + * @return Returns a pointer to OH_Drawing_FontFullDescriptor at the specified index. + * Returns NULL if the index is out of bounds or the array is invalid. + * @since 21 + */ +OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex(OH_Drawing_Array* fullNameArray, size_t index); + +/** + * @brief Retrieves an integer attribute value from a font full descriptor. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param descriptor Pointer to the font descriptor OH_Drawing_FontFullDescriptor. + * @param id Attribute identifier from OH_Drawing_FontFullDescriptorAttributeId enumeration. + * @param value Output parameter to receive the requested integer attribute value. + * @return Returns OH_Drawing_ErrorCode indicating operation status: + * - OH_DRAWING_SUCCESS (0) if successful + * - OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE (26200001) if attribute ID is invalid + * - OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH (26200003) if parameter type mismatch occurs + * @since 21 + */ +OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeInt(OH_Drawing_FontFullDescriptor* descriptor, + OH_Drawing_FontFullDescriptorAttributeId id, int* value); + +/** + * @brief Retrieves a boolean attribute value from a font full descriptor. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param descriptor Pointer to the font descriptor OH_Drawing_FontFullDescriptor. + * @param id Attribute identifier from OH_Drawing_FontFullDescriptorAttributeId enumeration. + * @param value Output parameter to receive the requested boolean attribute value. + * @return Returns OH_Drawing_ErrorCode indicating operation status: + * - OH_DRAWING_SUCCESS (0) if successful + * - OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE (26200001) if attribute ID is invalid + * - OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH (26200003) if parameter type mismatch occurs + * @since 21 + */ +OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(OH_Drawing_FontFullDescriptor* descriptor, + OH_Drawing_FontFullDescriptorAttributeId id, bool* value); + +/** + * @brief Retrieves a string attribute value from a font full descriptor. + * + * @note The returned OH_Drawing_String object must be manually released by the caller. + * Both the string object itself and its internal strData member must be freed. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param descriptor Pointer to the font descriptor OH_Drawing_FontFullDescriptor. + * @param id Attribute identifier from OH_Drawing_FontFullDescriptorAttributeId enumeration. + * @param str Output parameter to receive pointer to the requested string attribute value. + * @return Returns OH_Drawing_ErrorCode indicating operation status: + * - OH_DRAWING_SUCCESS (0) if successful + * - OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE (26200001) if attribute ID is invalid + * - OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH (26200003) if parameter type mismatch occurs + * @since 21 + */ +OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeString(OH_Drawing_FontFullDescriptor* descriptor, + OH_Drawing_FontFullDescriptorAttributeId id, OH_Drawing_String** str); #ifdef __cplusplus } #endif -- Gitee From 45b43298cf6c7747f28459bfc958770972c9e8b9 Mon Sep 17 00:00:00 2001 From: liufei Date: Wed, 10 Sep 2025 09:14:11 +0800 Subject: [PATCH 02/12] feat(graphic): add font full descriptor attribute enum and new API - Add OH_Drawing_FontFullDescriptorAtrributeId enum for font full descriptor attributes - Implement new API OH_Drawing_GetFontFullDescriptorssFromPath to get font full descriptors from file path - Update existing API OH_Drawing_GetFontFullDescriptorsFromStream for consistency Signed-off-by: liufei --- .../drawing_text_font_descriptor.h | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) 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 c0b0dc6e3e1..438259802bf 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -68,6 +68,34 @@ typedef enum { CUSTOMIZED = 1 << 4, } OH_Drawing_SystemFontType; +/** + * @brief An enumeration of font full descriptor attribute. + * + * @since 22 + */ +typedef enum { + /** The file path of the font */ + FULL_DESCRIPTOR_ATTR_S_PATH = 0, + /** A name that uniquely identifies the font */ + FULL_DESCRIPTOR_ATTR_S_POSTSRIPT_NAME = 1, + /** The full name of the font */ + FULL_DESCRIPTOR_ATTR_S_FULL_NAME = 2, + /** The family name of the font */ + FULL_DESCRIPTOR_ATTR_S_FAMILY_NAME = 3, + /** The subfont family of the font */ + FULL_DESCRIPTOR_ATTR_S_SUB_FAMILY_NAME = 4, + /** The weight of the font */ + FULL_DESCRIPTOR_ATTR_I_WEIGHT = 5, + /** The width of the font */ + FULL_DESCRIPTOR_ATTR_I_WIDTH = 6, + /** Whether the font is tilted */ + FULL_DESCRIPTOR_ATTR_I_ITALIC = 7, + /** Whether the font is monospaced */ + FULL_DESCRIPTOR_ATTR_B_MONO = 8, + /** whether symbolic fonts are supported */ + FULL_DESCRIPTOR_ATTR_B_SYMBOLIC = 9, +} OH_Drawing_FontFullDescriptorAtrributeId; + /** * @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 @@ -151,6 +179,16 @@ void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array* fullNameArray); */ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(OH_Drawing_MemoryStream* stream); +/** + * @brief Obtains an array of font full descriptors from font file path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path Indicates the pointer to the path to set. + * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. + * An empty array will be returned if no fonts are found, invalid path, no permission, or non-font file. + * @since 22 + */ +OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorssFromPath(char* path); /** * @brief Retrieves a font full descriptor from an array by index. -- Gitee From 39e7e0f27c7e1f90aa01aa19363234597678ef6d Mon Sep 17 00:00:00 2001 From: liufei Date: Wed, 10 Sep 2025 09:59:15 +0800 Subject: [PATCH 03/12] refactor(graphic): update font descriptor API version - Update the @since tag for font descriptor-related functions from 21 to 22 - This change reflects the evolution of the API to the next version Signed-off-by: liufei --- .../native_drawing/drawing_text_font_descriptor.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 438259802bf..e18c12fbf7b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -175,7 +175,7 @@ void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array* fullNameArray); * @param stream Indicates the pointer to the memory stream OH_Drawing_MemoryStream containing font data. * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. * Returns NULL if parsing fails or the stream contains invalid data. - * @since 21 + * @since 22 */ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(OH_Drawing_MemoryStream* stream); @@ -201,7 +201,7 @@ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorssFromPath(char* path); * @param index Zero-based index position of the descriptor to retrieve. * @return Returns a pointer to OH_Drawing_FontFullDescriptor at the specified index. * Returns NULL if the index is out of bounds or the array is invalid. - * @since 21 + * @since 22 */ OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex(OH_Drawing_Array* fullNameArray, size_t index); @@ -216,7 +216,7 @@ OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex(OH_Drawin * - OH_DRAWING_SUCCESS (0) if successful * - OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE (26200001) if attribute ID is invalid * - OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH (26200003) if parameter type mismatch occurs - * @since 21 + * @since 22 */ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeInt(OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, int* value); @@ -232,7 +232,7 @@ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeInt(OH_Drawing_Fon * - OH_DRAWING_SUCCESS (0) if successful * - OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE (26200001) if attribute ID is invalid * - OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH (26200003) if parameter type mismatch occurs - * @since 21 + * @since 22 */ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, bool* value); @@ -251,7 +251,7 @@ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(OH_Drawing_Fo * - OH_DRAWING_SUCCESS (0) if successful * - OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE (26200001) if attribute ID is invalid * - OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH (26200003) if parameter type mismatch occurs - * @since 21 + * @since 22 */ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeString(OH_Drawing_FontFullDescriptor* descriptor, OH_Drawing_FontFullDescriptorAttributeId id, OH_Drawing_String** str); -- Gitee From 13f76c7fd6f3577bdf5e0af30ced22a893aa01ec Mon Sep 17 00:00:00 2001 From: liufei Date: Wed, 10 Sep 2025 10:13:47 +0800 Subject: [PATCH 04/12] fix(graphic): correct return value description for OH_Drawing_GetFontFullDescriptorssFromPath - Update the function documentation to accurately reflect the return value in case of errors - Change from returning an empty array to returning NULL when no fonts are found or an error occurs Signed-off-by: liufei --- .../graphic_2d/native_drawing/drawing_text_font_descriptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e18c12fbf7b..e7838af0856 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -185,7 +185,7 @@ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(OH_Drawing_MemoryS * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param path Indicates the pointer to the path to set. * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. - * An empty array will be returned if no fonts are found, invalid path, no permission, or non-font file. + * Returns NULL if no fonts are found, invalid path, no permission, or non-font file. * @since 22 */ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorssFromPath(char* path); -- Gitee From 75976e439de78e49a68f2cddd5d8e06c4b7c0592 Mon Sep 17 00:00:00 2001 From: liufei Date: Wed, 10 Sep 2025 14:21:58 +0800 Subject: [PATCH 05/12] docs(graphic): remove redundant comment in Font API documentation - Removed unnecessary comment lines in the drawing_text_font_descriptor.h file - Improved readability and conciseness of the API documentation Signed-off-by: liufei --- .../graphic_2d/native_drawing/drawing_text_font_descriptor.h | 3 --- 1 file changed, 3 deletions(-) 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 e7838af0856..37d8910cdc6 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -193,9 +193,6 @@ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorssFromPath(char* path); /** * @brief Retrieves a font full descriptor from an array by index. * - * This function accesses a specific font descriptor within an array of font full descriptors - * obtained from OH_Drawing_GetFontFullDescriptorsFromStream. - * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param fullNameArray Pointer to the array of font descriptors OH_Drawing_Array. * @param index Zero-based index position of the descriptor to retrieve. -- Gitee From c237ee1a856323743cfd4bbebb27642da4a2a38b Mon Sep 17 00:00:00 2001 From: liufei Date: Wed, 10 Sep 2025 18:00:22 +0800 Subject: [PATCH 06/12] refactor(graphic): fix typos in font descriptor enum and function names - Correct spelling of enum value from POSTSRIPT_NAME to POSTSCRIPT_NAME - Correct spelling of struct name from FontFullDescriptorAtrributeId to FontFullDescriptorAttributeId - Correct function name from GetFontFullDescriptorssFromPath to GetFontFullDescriptorsFromPath Signed-off-by: liufei --- .../native_drawing/drawing_text_font_descriptor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 37d8910cdc6..ab3b67f7c56 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -77,7 +77,7 @@ typedef enum { /** The file path of the font */ FULL_DESCRIPTOR_ATTR_S_PATH = 0, /** A name that uniquely identifies the font */ - FULL_DESCRIPTOR_ATTR_S_POSTSRIPT_NAME = 1, + FULL_DESCRIPTOR_ATTR_S_POSTSCRIPT_NAME = 1, /** The full name of the font */ FULL_DESCRIPTOR_ATTR_S_FULL_NAME = 2, /** The family name of the font */ @@ -94,7 +94,7 @@ typedef enum { FULL_DESCRIPTOR_ATTR_B_MONO = 8, /** whether symbolic fonts are supported */ FULL_DESCRIPTOR_ATTR_B_SYMBOLIC = 9, -} OH_Drawing_FontFullDescriptorAtrributeId; +} OH_Drawing_FontFullDescriptorAttributeId; /** * @brief Obtain all system font descriptive symbols that match the specified font descriptor. Where the 'path' @@ -188,7 +188,7 @@ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(OH_Drawing_MemoryS * Returns NULL if no fonts are found, invalid path, no permission, or non-font file. * @since 22 */ -OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorssFromPath(char* path); +OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromPath(char* path); /** * @brief Retrieves a font full descriptor from an array by index. -- Gitee From e8cdf4ecbc6b793de46f5460401184a24cbdb6c9 Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 11 Sep 2025 10:16:18 +0800 Subject: [PATCH 07/12] refactor(graphic): update font descriptor attribute string handling - Remove unnecessary pointer indirection for OH_Drawing_String parameter - Update documentation to clarify memory management responsibility Signed-off-by: liufei --- .../native_drawing/drawing_text_font_descriptor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 ab3b67f7c56..97bc63df396 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -237,8 +237,8 @@ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(OH_Drawing_Fo /** * @brief Retrieves a string attribute value from a font full descriptor. * - * @note The returned OH_Drawing_String object must be manually released by the caller. - * Both the string object itself and its internal strData member must be freed. + * @note The caller is responsible for manually releasing the internal strData member of the + * OH_Drawing_String structure when it is no longer needed. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param descriptor Pointer to the font descriptor OH_Drawing_FontFullDescriptor. @@ -251,7 +251,7 @@ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(OH_Drawing_Fo * @since 22 */ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeString(OH_Drawing_FontFullDescriptor* descriptor, - OH_Drawing_FontFullDescriptorAttributeId id, OH_Drawing_String** str); + OH_Drawing_FontFullDescriptorAttributeId id, OH_Drawing_String* str); #ifdef __cplusplus } #endif -- Gitee From 9a1cded94a3b21ae033b1aa0e5b92d175f82fd2b Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 11 Sep 2025 15:16:32 +0800 Subject: [PATCH 08/12] add OH_Drawing_FontFullDescriptor Signed-off-by: liufei --- .../graphic_2d/native_drawing/drawing_text_declaration.h | 6 ++++++ .../native_drawing/drawing_text_font_descriptor.h | 1 + 2 files changed, 7 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index a005e95af4f..d2313551dcd 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h @@ -157,6 +157,12 @@ typedef struct OH_Drawing_TextLine OH_Drawing_TextLine; */ typedef struct OH_Drawing_Run OH_Drawing_Run; +/** + * @brief Describes the font information. + * + * @since 22 + */ +typedef struct OH_Drawing_FontFullDescriptor OH_Drawing_FontFullDescriptor; #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 index 97bc63df396..4e8270bdaf1 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -41,6 +41,7 @@ #define DRAWING_TEXT_FONT_DESCRIPTOR_H #include "drawing_memory_stream.h" +#include "drawing_text_declaration.h" #include "drawing_text_typography.h" #ifdef __cplusplus -- Gitee From 6c1052207e37671a26146db0c9f422a54c3ef556 Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 11 Sep 2025 16:23:19 +0800 Subject: [PATCH 09/12] refactor(graphic_2d/native_drawing): Update parameter names and add function for destroying font descriptors - Renamed `fullNameArray` to `descriptorArray` in `OH_Drawing_GetFontFullDescriptorByIndex` for clarity. - Changed the return type of `OH_Drawing_GetFontFullDescriptorByIndex` to `const OH_Drawing_FontFullDescriptor*`. - Added a new function `OH_Drawing_DestroyFontFullDescriptors` to release memory occupied by an array of font full descriptors. - Updated comments and parameter descriptions for better documentation. Signed-off-by: liufei --- .../drawing_text_font_descriptor.h | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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 4e8270bdaf1..27157f65848 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -195,19 +195,30 @@ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromPath(char* path); * @brief Retrieves a font full descriptor from an array by index. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param fullNameArray Pointer to the array of font descriptors OH_Drawing_Array. + * @param descriptorArray Pointer to the array of font full descriptors OH_Drawing_Array. * @param index Zero-based index position of the descriptor to retrieve. * @return Returns a pointer to OH_Drawing_FontFullDescriptor at the specified index. * Returns NULL if the index is out of bounds or the array is invalid. * @since 22 */ -OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex(OH_Drawing_Array* fullNameArray, size_t index); + +const OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex( + OH_Drawing_Array* descriptorArray, size_t index); + +/** + * @brief Releases the memory occupied by an array of font full descriptors. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param descriptorArray Pointer to the array of font full descriptors OH_Drawing_Array. + * @since 22 + */ +void OH_Drawing_DestroyFontFullDescriptors(OH_Drawing_Array* descriptorArray, size_t index); /** * @brief Retrieves an integer attribute value from a font full descriptor. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param descriptor Pointer to the font descriptor OH_Drawing_FontFullDescriptor. + * @param descriptor Pointer to the font full descriptor OH_Drawing_FontFullDescriptor. * @param id Attribute identifier from OH_Drawing_FontFullDescriptorAttributeId enumeration. * @param value Output parameter to receive the requested integer attribute value. * @return Returns OH_Drawing_ErrorCode indicating operation status: @@ -223,7 +234,7 @@ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeInt(OH_Drawing_Fon * @brief Retrieves a boolean attribute value from a font full descriptor. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param descriptor Pointer to the font descriptor OH_Drawing_FontFullDescriptor. + * @param descriptor Pointer to the font full descriptor OH_Drawing_FontFullDescriptor. * @param id Attribute identifier from OH_Drawing_FontFullDescriptorAttributeId enumeration. * @param value Output parameter to receive the requested boolean attribute value. * @return Returns OH_Drawing_ErrorCode indicating operation status: @@ -242,7 +253,7 @@ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(OH_Drawing_Fo * OH_Drawing_String structure when it is no longer needed. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param descriptor Pointer to the font descriptor OH_Drawing_FontFullDescriptor. + * @param descriptor Pointer to the font full descriptor OH_Drawing_FontFullDescriptor. * @param id Attribute identifier from OH_Drawing_FontFullDescriptorAttributeId enumeration. * @param str Output parameter to receive pointer to the requested string attribute value. * @return Returns OH_Drawing_ErrorCode indicating operation status: -- Gitee From db3e3646d61049cd42c0abc31c8820d820f6ed18 Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 11 Sep 2025 16:41:03 +0800 Subject: [PATCH 10/12] remove white space Signed-off-by: liufei --- .../native_drawing/drawing_text_font_descriptor.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 27157f65848..11b23b447ce 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -75,7 +75,7 @@ typedef enum { * @since 22 */ typedef enum { - /** The file path of the font */ + /** The file path of the font */ FULL_DESCRIPTOR_ATTR_S_PATH = 0, /** A name that uniquely identifies the font */ FULL_DESCRIPTOR_ATTR_S_POSTSCRIPT_NAME = 1, @@ -174,7 +174,7 @@ void OH_Drawing_DestroySystemFontFullNames(OH_Drawing_Array* fullNameArray); * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param stream Indicates the pointer to the memory stream OH_Drawing_MemoryStream containing font data. - * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. + * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. * Returns NULL if parsing fails or the stream contains invalid data. * @since 22 */ @@ -185,7 +185,7 @@ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromStream(OH_Drawing_MemoryS * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param path Indicates the pointer to the path to set. - * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. + * @return Returns a pointer to OH_Drawing_Array structure containing font full descriptors. * Returns NULL if no fonts are found, invalid path, no permission, or non-font file. * @since 22 */ @@ -197,11 +197,10 @@ OH_Drawing_Array* OH_Drawing_GetFontFullDescriptorsFromPath(char* path); * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param descriptorArray Pointer to the array of font full descriptors OH_Drawing_Array. * @param index Zero-based index position of the descriptor to retrieve. - * @return Returns a pointer to OH_Drawing_FontFullDescriptor at the specified index. + * @return Returns a pointer to OH_Drawing_FontFullDescriptor at the specified index. * Returns NULL if the index is out of bounds or the array is invalid. * @since 22 */ - const OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex( OH_Drawing_Array* descriptorArray, size_t index); @@ -249,7 +248,7 @@ OH_Drawing_ErrorCode OH_Drawing_GetFontFullDescriptorAttributeBool(OH_Drawing_Fo /** * @brief Retrieves a string attribute value from a font full descriptor. * - * @note The caller is responsible for manually releasing the internal strData member of the + * @note The caller is responsible for manually releasing the internal strData member of the * OH_Drawing_String structure when it is no longer needed. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing -- Gitee From 61550bdd7a951b465f1534e58f6168e54e555ffa Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 11 Sep 2025 16:57:03 +0800 Subject: [PATCH 11/12] update OH_Drawing_FontFullDescriptor docs Signed-off-by: liufei --- graphic/graphic_2d/native_drawing/drawing_text_declaration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h index d2313551dcd..a6c2578bbf6 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_declaration.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_declaration.h @@ -158,7 +158,7 @@ typedef struct OH_Drawing_TextLine OH_Drawing_TextLine; typedef struct OH_Drawing_Run OH_Drawing_Run; /** - * @brief Describes the font information. + * @brief Defines an OH_Drawing_FontFullDescriptor, which describes the font information. * * @since 22 */ -- Gitee From ceca6609636d86d68ad8bf826f2ad8ca0e28ff7f Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 11 Sep 2025 17:04:53 +0800 Subject: [PATCH 12/12] remove param Signed-off-by: liufei --- .../graphic_2d/native_drawing/drawing_text_font_descriptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 11b23b447ce..40f7de8bbb1 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h @@ -211,7 +211,7 @@ const OH_Drawing_FontFullDescriptor* OH_Drawing_GetFontFullDescriptorByIndex( * @param descriptorArray Pointer to the array of font full descriptors OH_Drawing_Array. * @since 22 */ -void OH_Drawing_DestroyFontFullDescriptors(OH_Drawing_Array* descriptorArray, size_t index); +void OH_Drawing_DestroyFontFullDescriptors(OH_Drawing_Array* descriptorArray); /** * @brief Retrieves an integer attribute value from a font full descriptor. -- Gitee