From 7bc25f7a6e63323ba872af710c78915805f34d01 Mon Sep 17 00:00:00 2001 From: mobHot Date: Wed, 21 May 2025 15:22:55 +0800 Subject: [PATCH 1/2] add the interface of glyph drawing. Signed-off-by: mobHot Change-Id: If0ea70672777e3247722d2435e6caab62edf90b0 --- .../native_drawing/drawing_text_run.h | 54 +++++++++++++++++++ .../native_drawing/drawing_text_typography.h | 11 ++++ .../native_drawing/libnative_drawing.ndk.json | 24 +++++++++ 3 files changed, 89 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_run.h b/graphic/graphic_2d/native_drawing/drawing_text_run.h index 8873eaaf2..790efd05c 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_run.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_run.h @@ -41,6 +41,7 @@ #define C_INCLUDE_DRAWING_TEXT_RUN_H #include "drawing_text_declaration.h" +#include "drawing_text_typography.h" #include "drawing_types.h" #ifdef __cplusplus @@ -208,6 +209,59 @@ void OH_Drawing_DestroyRunPositions(OH_Drawing_Array* positions); * @since 18 */ uint32_t OH_Drawing_GetRunGlyphCount(OH_Drawing_Run* run); + +/** + * @brief Gets the Font Object of run. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @return The Font Object of run. + * @since 20 + * @version 1.0 + */ +OH_Drawing_Font* OH_Drawing_GetRunFont(OH_Drawing_Run* run); + +/** + * @brief Get the text direction. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param run Indicates the pointer to an OH_Drawing_Run object. + * @return Return the text direction of an OH_Drawing_TextDirection object. + * @since 20 + */ +OH_Drawing_TextDirection OH_Drawing_GetRunTextDirection(OH_Drawing_Run* run); + +/** + * @brief Gets the glyph width array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @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 Indicates the pointer to the glyph width array object OH_Drawing_Array. + * @since 20 + */ +OH_Drawing_Array* OH_Drawing_GetRunGlyphAdvances(OH_Drawing_Run* run, uint32_t start, uint32_t length); + +/** + * @brief Gets the glyph width by index. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param positions The glyph width array object OH_Drawing_Array. + * @param index The run of glyph index. + * @return The width of glyph. + * @since 20 + */ +double OH_Drawing_GetRunGlyphAdvanceByIndex(OH_Drawing_Array* advances, size_t index); + +/** + * @brief Releases the memory of glyph width array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param advances The run of glyph width array object OH_Drawing_Array. + * @since 20 + */ +void OH_Drawing_DestroyRunGlyphAdvances(OH_Drawing_Array* advances); #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_text_typography.h b/graphic/graphic_2d/native_drawing/drawing_text_typography.h index 8a704ced5..712747bca 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_typography.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_typography.h @@ -2683,6 +2683,17 @@ void OH_Drawing_TypographyUpdateDecorationThicknessScale(OH_Drawing_Typography* void OH_Drawing_TypographyUpdateDecorationStyle(OH_Drawing_Typography* typography, OH_Drawing_TextDecorationStyle decorationStyle); +/** + * @brief Updates the decoration color of the paragraph. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param typography Indicates the pointer to the text OH_Drawing_Typography object. + * @param color Indicates the text decoration color to update. + * @since 20 + * @version 1.0 + */ +void OH_Drawing_TypographyUpdateDecorationColor(OH_Drawing_Typography* typography, uint32_t color); + /** * @brief Get whether the text layout enables line styles. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index cf0944999..7fa265331 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1534,6 +1534,10 @@ "first_introduced": "20", "name": "OH_Drawing_TypographyUpdateDecorationStyle" }, + { + "first_introduced": "20", + "name": "OH_Drawing_TypographyUpdateDecorationColor" + }, { "first_introduced": "12", "name": "OH_Drawing_TypographyTextGetLineStyle" @@ -1834,10 +1838,30 @@ "first_introduced": "18", "name":"OH_Drawing_GetRunGlyphCount" }, + { + "first_introduced": "20", + "name":"OH_Drawing_GetRunTextDirection" + }, + { + "first_introduced": "20", + "name":"OH_Drawing_GetRunGlyphAdvances" + }, + { + "first_introduced": "20", + "name":"OH_Drawing_GetRunGlyphAdvanceByIndex" + }, + { + "first_introduced": "20", + "name":"OH_Drawing_DestroyRunGlyphAdvances" + }, { "first_introduced": "14", "name":"OH_Drawing_GetFontCollectionGlobalInstance" }, + { + "first_introduced": "20", + "name":"OH_Drawing_GetRunFont" + }, { "first_introduced": "18", "name":"OH_Drawing_CanvasQuickRejectPath" -- Gitee From c298d52f7b2a0f1609aa00396f61b7e7a97e4231 Mon Sep 17 00:00:00 2001 From: mobHot Date: Tue, 27 May 2025 11:32:10 +0800 Subject: [PATCH 2/2] fix the interface Signed-off-by: mobHot Change-Id: I499d22cf721b211c5bb43ff9574435e1cb56bd33 --- .../graphic_2d/native_drawing/drawing_text_run.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_text_run.h b/graphic/graphic_2d/native_drawing/drawing_text_run.h index 790efd05c..cd9dff6ea 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_run.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_run.h @@ -232,33 +232,33 @@ OH_Drawing_Font* OH_Drawing_GetRunFont(OH_Drawing_Run* run); OH_Drawing_TextDirection OH_Drawing_GetRunTextDirection(OH_Drawing_Run* run); /** - * @brief Gets the glyph width array. + * @brief Gets the glyph advance array. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @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 Indicates the pointer to the glyph width array object OH_Drawing_Array. + * @return Indicates the pointer to the glyph advance array object OH_Drawing_Array. * @since 20 */ OH_Drawing_Array* OH_Drawing_GetRunGlyphAdvances(OH_Drawing_Run* run, uint32_t start, uint32_t length); /** - * @brief Gets the glyph width by index. + * @brief Gets the glyph advance by index. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param positions The glyph width array object OH_Drawing_Array. + * @param advances The glyph advance array object OH_Drawing_Array. * @param index The run of glyph index. - * @return The width of glyph. + * @return Run of glyph advance pointer to an OH_Drawing_Point object. * @since 20 */ -double OH_Drawing_GetRunGlyphAdvanceByIndex(OH_Drawing_Array* advances, size_t index); +OH_Drawing_Point* OH_Drawing_GetRunGlyphAdvanceByIndex(OH_Drawing_Array* advances, size_t index); /** - * @brief Releases the memory of glyph width array. + * @brief Releases the memory of glyph advance array. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing - * @param advances The run of glyph width array object OH_Drawing_Array. + * @param advances The run of glyph advance array object OH_Drawing_Array. * @since 20 */ void OH_Drawing_DestroyRunGlyphAdvances(OH_Drawing_Array* advances); -- Gitee