From 48a3e97e9f77fe4fcdf192c755b8c7e0b8f83a6c Mon Sep 17 00:00:00 2001 From: FTL1ght Date: Tue, 12 Aug 2025 14:46:03 +0800 Subject: [PATCH 1/7] LineHeight interface for c Signed-off-by: FTL1ght Change-Id: I79e0ea7c29befd4fa2accdc2eacab64ad88e5db0 --- .../native_drawing/drawing_text_typography.h | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 9bdf581f61d..4635826e802 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -582,6 +582,151 @@ typedef enum OH_Drawing_FontWidth { FONT_WIDTH_ULTRA_EXPANDED = 9, } OH_Drawing_FontWidth; +/** + * @brief Enumerates text style attribute. + * + * @since 21 + */ +typedef enum OH_Drawing_TextStyleAttributeId { + /** Line height maximum */ + TEXT_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0, + /** Line height minimum */ + TEXT_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1, + /** Line spacing */ + TEXT_STYLE_ATTR_D_LINE_SPACING = 2, + /** Line height style */ + TEXT_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 3, + /** Font width */ + TEXT_STYLE_ATTR_I_FONT_WIDTH = 4, +} OH_Drawing_TextStyleAttributeId; + +/** + * @brief Enumerates line height's scaling type. + * + * @since 21 + */ +typedef enum OH_Drawing_LineHeightStyle{ + /** Use the font size as the scale factor for line height scaling */ + TEXT_LINE_HEIGHT_BY_FONT_SIZE = 0, + /** Use the text height after shaping as the scale factor for line height scaling */ + TEXT_LINE_HEIGHT_BY_FONT_HEIGHT = 1, +} OH_Drawing_LineHeightStyle; + +/** + * @brief Enumerates typography style attribute. + * + * @since 21 + */ +typedef enum OH_Drawing_TypographyStyleAttributeId { + /** Line height maximum */ + TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0, + /** Line height minimum */ + TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1, + /** Line spacing */ + TYPOGRAPHY_STYLE_ATTR_D_LINE_SPACING = 2, + /** Line height style */ + TYPOGRAPHY_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 3, + /** Font width */ + TYPOGRAPHY_STYLE_ATTR_I_FONT_WIDTH = 4, +} OH_Drawing_TypographyStyleAttributeId; + +/** + * @brief Sets double value to the text style attribute. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TextStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the value to set. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double value); + +/** + * @brief Gets the double type property's value from the text style. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TextStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the return value of the interface. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_GetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double* value); + +/** + * @brief Sets int value to the text style attribute. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TextStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the value to set. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int value); + +/** + * @brief Gets the int type property's value from the text style. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TextStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the return value of the interface. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_GetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int* value); + +/** + * @brief Sets double value to the typography style attribute. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the value to set. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double value); + +/** + * @brief Gets the double type property's value from the typography style. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the return value of the interface. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_GetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double* value); + +/** + * @brief Sets int value to the typography style attribute. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the value to set. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int value); + +/** + * @brief Gets the int type property's value from the typography style. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. + * @param id Indicates the attribute id. + * @param value Indicates the return value of the interface. + * @return Returns interface call status. + * @since 21 + */ +int OH_Drawing_GetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int* value); + + /** * @brief Type of badge. * -- Gitee From 2d36bcfa6f5c7fb160647f7d778c3aa3d8b6b23a Mon Sep 17 00:00:00 2001 From: FTL1ght Date: Mon, 25 Aug 2025 19:25:23 +0800 Subject: [PATCH 2/7] Attribute partitioning Signed-off-by: FTL1ght Change-Id: Icb8507f2e42aeca8a7f4d0065481c738aea0f5a1 --- .../native_drawing/drawing_text_typography.h | 47 ++++++++++--------- .../native_drawing/libnative_drawing.ndk.json | 32 +++++++++++++ 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 4635826e802..d707b7ac9b7 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -589,15 +589,13 @@ typedef enum OH_Drawing_FontWidth { */ typedef enum OH_Drawing_TextStyleAttributeId { /** Line height maximum */ - TEXT_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0, + TEXT_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 100, /** Line height minimum */ - TEXT_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1, - /** Line spacing */ - TEXT_STYLE_ATTR_D_LINE_SPACING = 2, + TEXT_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 101, /** Line height style */ - TEXT_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 3, + TEXT_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 102, /** Font width */ - TEXT_STYLE_ATTR_I_FONT_WIDTH = 4, + TEXT_STYLE_ATTR_I_FONT_WIDTH = 103, } OH_Drawing_TextStyleAttributeId; /** @@ -605,7 +603,7 @@ typedef enum OH_Drawing_TextStyleAttributeId { * * @since 21 */ -typedef enum OH_Drawing_LineHeightStyle{ +typedef enum OH_Drawing_LineHeightStyle { /** Use the font size as the scale factor for line height scaling */ TEXT_LINE_HEIGHT_BY_FONT_SIZE = 0, /** Use the text height after shaping as the scale factor for line height scaling */ @@ -619,15 +617,15 @@ typedef enum OH_Drawing_LineHeightStyle{ */ typedef enum OH_Drawing_TypographyStyleAttributeId { /** Line height maximum */ - TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0, + TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 300, /** Line height minimum */ - TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1, + TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 301, /** Line spacing */ - TYPOGRAPHY_STYLE_ATTR_D_LINE_SPACING = 2, + TYPOGRAPHY_STYLE_ATTR_D_LINE_SPACING = 302, /** Line height style */ - TYPOGRAPHY_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 3, + TYPOGRAPHY_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 303, /** Font width */ - TYPOGRAPHY_STYLE_ATTR_I_FONT_WIDTH = 4, + TYPOGRAPHY_STYLE_ATTR_I_FONT_WIDTH = 304, } OH_Drawing_TypographyStyleAttributeId; /** @@ -640,7 +638,8 @@ typedef enum OH_Drawing_TypographyStyleAttributeId { * @return Returns interface call status. * @since 21 */ -int OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double value); +int OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, + OH_Drawing_TextStyleAttributeId id, double value); /** * @brief Gets the double type property's value from the text style. @@ -652,7 +651,8 @@ int OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawi * @return Returns interface call status. * @since 21 */ -int OH_Drawing_GetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double* value); +int OH_Drawing_GetTextStyleAttributeDouble(const OH_Drawing_TextStyle* style, + OH_Drawing_TextStyleAttributeId id, double* value); /** * @brief Sets int value to the text style attribute. @@ -664,7 +664,8 @@ int OH_Drawing_GetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawi * @return Returns interface call status. * @since 21 */ -int OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int value); +int OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, + OH_Drawing_TextStyleAttributeId id, int value); /** * @brief Gets the int type property's value from the text style. @@ -676,7 +677,8 @@ int OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_ * @return Returns interface call status. * @since 21 */ -int OH_Drawing_GetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int* value); +int OH_Drawing_GetTextStyleAttributeInt(const OH_Drawing_TextStyle* style, + OH_Drawing_TextStyleAttributeId id, int* value); /** * @brief Sets double value to the typography style attribute. @@ -688,7 +690,8 @@ int OH_Drawing_GetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_ * @return Returns interface call status. * @since 21 */ -int OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double value); +int OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, + OH_Drawing_TypographyStyleAttributeId id, double value); /** * @brief Gets the double type property's value from the typography style. @@ -700,7 +703,8 @@ int OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* sty * @return Returns interface call status. * @since 21 */ -int OH_Drawing_GetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double* value); +int OH_Drawing_GetTypographyStyleAttributeDouble(const OH_Drawing_TypographyStyle* style, + OH_Drawing_TypographyStyleAttributeId id, double* value); /** * @brief Sets int value to the typography style attribute. @@ -712,7 +716,8 @@ int OH_Drawing_GetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* sty * @return Returns interface call status. * @since 21 */ -int OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int value); +int OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, + OH_Drawing_TypographyStyleAttributeId id, int value); /** * @brief Gets the int type property's value from the typography style. @@ -724,8 +729,8 @@ int OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, * @return Returns interface call status. * @since 21 */ -int OH_Drawing_GetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int* value); - +int OH_Drawing_GetTypographyStyleAttributeInt(const OH_Drawing_TypographyStyle* style, + OH_Drawing_TypographyStyleAttributeId id, int* value); /** * @brief Type of badge. diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 7472ebb0798..dd7a4376023 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -2037,5 +2037,37 @@ { "first_introduced": "20", "name": "OH_Drawing_FontFeaturesDestroy" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_SetTextStyleAttributeDouble" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_GetTextStyleAttributeDouble" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_SetTextStyleAttributeInt" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_GetTextStyleAttributeInt" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_SetTypographyStyleAttributeDouble" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_GetTypographyStyleAttributeDouble" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_SetTypographyStyleAttributeInt" + }, + { + "first_introduced": "21", + "name": "OH_Drawing_GetTypographyStyleAttributeInt" } ] \ No newline at end of file -- Gitee From 6aa6fa4f2e8eb3d37931b07a9ff5c2221d814b94 Mon Sep 17 00:00:00 2001 From: FTL1ght Date: Wed, 27 Aug 2025 16:49:47 +0800 Subject: [PATCH 3/7] Format error code Signed-off-by: FTL1ght Change-Id: I7a1570f54c494feae7be2a162f9593e6ac6135fc --- .../native_drawing/drawing_text_typography.h | 72 ++++++++++++++----- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index d707b7ac9b7..810a0e0d837 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -635,10 +635,15 @@ typedef enum OH_Drawing_TypographyStyleAttributeId { * @param style Indicates the pointer to an OH_Drawing_TextStyle object. * @param id Indicates the attribute id. * @param value Indicates the value to set. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, +OH_Drawing_ErrorCode OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double value); /** @@ -648,10 +653,15 @@ int OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle* style, * @param style Indicates the pointer to an OH_Drawing_TextStyle object. * @param id Indicates the attribute id. * @param value Indicates the return value of the interface. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_GetTextStyleAttributeDouble(const OH_Drawing_TextStyle* style, +OH_Drawing_ErrorCode OH_Drawing_GetTextStyleAttributeDouble(const OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, double* value); /** @@ -661,10 +671,15 @@ int OH_Drawing_GetTextStyleAttributeDouble(const OH_Drawing_TextStyle* style, * @param style Indicates the pointer to an OH_Drawing_TextStyle object. * @param id Indicates the attribute id. * @param value Indicates the value to set. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, +OH_Drawing_ErrorCode OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int value); /** @@ -674,10 +689,15 @@ int OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* style, * @param style Indicates the pointer to an OH_Drawing_TextStyle object. * @param id Indicates the attribute id. * @param value Indicates the return value of the interface. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_GetTextStyleAttributeInt(const OH_Drawing_TextStyle* style, +OH_Drawing_ErrorCode OH_Drawing_GetTextStyleAttributeInt(const OH_Drawing_TextStyle* style, OH_Drawing_TextStyleAttributeId id, int* value); /** @@ -687,10 +707,15 @@ int OH_Drawing_GetTextStyleAttributeInt(const OH_Drawing_TextStyle* style, * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. * @param id Indicates the attribute id. * @param value Indicates the value to set. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, +OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double value); /** @@ -700,10 +725,15 @@ int OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_TypographyStyle* sty * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. * @param id Indicates the attribute id. * @param value Indicates the return value of the interface. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_GetTypographyStyleAttributeDouble(const OH_Drawing_TypographyStyle* style, +OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeDouble(const OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, double* value); /** @@ -713,10 +743,15 @@ int OH_Drawing_GetTypographyStyleAttributeDouble(const OH_Drawing_TypographyStyl * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. * @param id Indicates the attribute id. * @param value Indicates the value to set. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, +OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int value); /** @@ -726,10 +761,15 @@ int OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_TypographyStyle* style, * @param style Indicates the pointer to an OH_Drawing_TypographyStyle object. * @param id Indicates the attribute id. * @param value Indicates the return value of the interface. - * @return Returns interface call status. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. + * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. + * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id + * exceeds the allowable range. * @since 21 */ -int OH_Drawing_GetTypographyStyleAttributeInt(const OH_Drawing_TypographyStyle* style, +OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeInt(const OH_Drawing_TypographyStyle* style, OH_Drawing_TypographyStyleAttributeId id, int* value); /** -- Gitee From e4879478d0ad1ed7a2ff60e499881c8d4d0e0c74 Mon Sep 17 00:00:00 2001 From: FTL1ght Date: Wed, 27 Aug 2025 17:18:57 +0800 Subject: [PATCH 4/7] Format enum Signed-off-by: FTL1ght Change-Id: Idccc05c8edcd4e497583954e316a24e1a5a57da5 --- .../native_drawing/drawing_text_typography.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 810a0e0d837..82586696640 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -589,13 +589,13 @@ typedef enum OH_Drawing_FontWidth { */ typedef enum OH_Drawing_TextStyleAttributeId { /** Line height maximum */ - TEXT_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 100, + TEXT_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0, /** Line height minimum */ - TEXT_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 101, + TEXT_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1, /** Line height style */ - TEXT_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 102, + TEXT_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 2, /** Font width */ - TEXT_STYLE_ATTR_I_FONT_WIDTH = 103, + TEXT_STYLE_ATTR_I_FONT_WIDTH = 3, } OH_Drawing_TextStyleAttributeId; /** @@ -617,15 +617,15 @@ typedef enum OH_Drawing_LineHeightStyle { */ typedef enum OH_Drawing_TypographyStyleAttributeId { /** Line height maximum */ - TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 300, + TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MAXIMUM = 0, /** Line height minimum */ - TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 301, + TYPOGRAPHY_STYLE_ATTR_D_LINE_HEIGHT_MINIMUM = 1, /** Line spacing */ - TYPOGRAPHY_STYLE_ATTR_D_LINE_SPACING = 302, + TYPOGRAPHY_STYLE_ATTR_D_LINE_SPACING = 2, /** Line height style */ - TYPOGRAPHY_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 303, + TYPOGRAPHY_STYLE_ATTR_I_LINE_HEIGHT_STYLE = 3, /** Font width */ - TYPOGRAPHY_STYLE_ATTR_I_FONT_WIDTH = 304, + TYPOGRAPHY_STYLE_ATTR_I_FONT_WIDTH = 4, } OH_Drawing_TypographyStyleAttributeId; /** -- Gitee From ac0a512bb1d6c8599991baf80b25046392d41185 Mon Sep 17 00:00:00 2001 From: FTL1ght Date: Wed, 27 Aug 2025 17:30:52 +0800 Subject: [PATCH 5/7] Add error code Signed-off-by: FTL1ght Change-Id: Ie8533f623f38b4f843c0bc6032b4f802e7058e16 --- graphic/graphic_2d/native_drawing/drawing_error_code.h | 5 +++++ graphic/graphic_2d/native_drawing/drawing_text_typography.h | 1 + 2 files changed, 6 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_error_code.h b/graphic/graphic_2d/native_drawing/drawing_error_code.h index 0c6e6e0c876..476e80bd962 100644 --- a/graphic/graphic_2d/native_drawing/drawing_error_code.h +++ b/graphic/graphic_2d/native_drawing/drawing_error_code.h @@ -70,6 +70,11 @@ typedef enum { * @since 13 */ OH_DRAWING_ERROR_ALLOCATION_FAILED = 26200002, + /** + * @error attribute id is not recognized or supported. + * @since 21 + */ + OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH = 26200003, } OH_Drawing_ErrorCode; /** diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 82586696640..14c83dcf7b0 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -48,6 +48,7 @@ #include #endif #include "drawing_canvas.h" +#include "drawing_error_code.h" #include "drawing_color.h" #include "drawing_font.h" #include "drawing_text_declaration.h" -- Gitee From 068a470f401966dcf54af96c577873d81ce509f0 Mon Sep 17 00:00:00 2001 From: FTL1ght Date: Thu, 28 Aug 2025 14:44:20 +0800 Subject: [PATCH 6/7] Fix description Signed-off-by: FTL1ght Change-Id: I20fa5ca4e9f225065f9ed34dd22b0c3817e9770e --- graphic/graphic_2d/native_drawing/drawing_error_code.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_error_code.h b/graphic/graphic_2d/native_drawing/drawing_error_code.h index 476e80bd962..239f948173b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_error_code.h +++ b/graphic/graphic_2d/native_drawing/drawing_error_code.h @@ -71,7 +71,7 @@ typedef enum { */ OH_DRAWING_ERROR_ALLOCATION_FAILED = 26200002, /** - * @error attribute id is not recognized or supported. + * @error The attribute id is not recognized or supported. * @since 21 */ OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH = 26200003, -- Gitee From 27e2d7188c4425273930113e441c1460cced69db Mon Sep 17 00:00:00 2001 From: FTL1ght Date: Thu, 28 Aug 2025 16:00:01 +0800 Subject: [PATCH 7/7] Remove useless returns Signed-off-by: FTL1ght Change-Id: Ifecd3ff3e6f57b5058b88b9cc2ded8e593532d33 --- .../graphic_2d/native_drawing/drawing_text_typography.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 14c83dcf7b0..42842a24a5e 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -658,8 +658,6 @@ OH_Drawing_ErrorCode OH_Drawing_SetTextStyleAttributeDouble(OH_Drawing_TextStyle * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. - * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id - * exceeds the allowable range. * @since 21 */ OH_Drawing_ErrorCode OH_Drawing_GetTextStyleAttributeDouble(const OH_Drawing_TextStyle* style, @@ -694,8 +692,6 @@ OH_Drawing_ErrorCode OH_Drawing_SetTextStyleAttributeInt(OH_Drawing_TextStyle* s * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. - * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id - * exceeds the allowable range. * @since 21 */ OH_Drawing_ErrorCode OH_Drawing_GetTextStyleAttributeInt(const OH_Drawing_TextStyle* style, @@ -730,8 +726,6 @@ OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeDouble(OH_Drawing_Typ * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. - * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id - * exceeds the allowable range. * @since 21 */ OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeDouble(const OH_Drawing_TypographyStyle* style, @@ -766,8 +760,6 @@ OH_Drawing_ErrorCode OH_Drawing_SetTypographyStyleAttributeInt(OH_Drawing_Typogr * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the style or value is nullptr. * Returns {@link OH_DRAWING_ERROR_ATTRIBUTE_ID_MISMATCH} if the attribute id is not recognized or supported. - * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if the value corresponding to the attribute id - * exceeds the allowable range. * @since 21 */ OH_Drawing_ErrorCode OH_Drawing_GetTypographyStyleAttributeInt(const OH_Drawing_TypographyStyle* style, -- Gitee