From 78d7a8ee6f62224fdfb5a2dd578e2f18eb496484 Mon Sep 17 00:00:00 2001 From: Lizhiqi Date: Fri, 20 Jun 2025 16:54:19 +0800 Subject: [PATCH] add measure for styledstring Signed-off-by: lizhiqi --- api/@internal/component/ets/text_common.d.ts | 18 ++++++++++++++++++ api/@ohos.arkui.UIContext.d.ts | 11 +++++++++++ 2 files changed, 29 insertions(+) diff --git a/api/@internal/component/ets/text_common.d.ts b/api/@internal/component/ets/text_common.d.ts index 3a06c41ef1..4f75e5b57c 100644 --- a/api/@internal/component/ets/text_common.d.ts +++ b/api/@internal/component/ets/text_common.d.ts @@ -2130,4 +2130,22 @@ declare interface IMEClient { * @since 20 */ nodeId: number; +} + +/** + * Defines text layout options. Use this to set constraints for measure text. + * + * @interface TextLayoutOptions + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +declare interface TextLayoutOptions { + /** + * Text display area of width. + * + * @type { ?LengthMetrics } constraintWidth + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + constraintWidth?: LengthMetrics; } \ No newline at end of file diff --git a/api/@ohos.arkui.UIContext.d.ts b/api/@ohos.arkui.UIContext.d.ts index c4a1bba7a9..db397035df 100755 --- a/api/@ohos.arkui.UIContext.d.ts +++ b/api/@ohos.arkui.UIContext.d.ts @@ -3049,6 +3049,17 @@ export class MeasureUtils { * @since 12 */ measureTextSize(options: MeasureOptions): SizeOptions; + + /** + * Get layout info of the styled string. + * + * @param { StyledString } styledString - The styled string value. + * @param { TextLayoutOptions } [options] - The layout options. + * @returns { Array } paragraph result + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + getParagraphs(styledString: StyledString, options?: TextLayoutOptions): Array; } /** -- Gitee