1# Text Component Common APIs 2 3>**NOTE** 4> 5>This topic covers the common APIs of text components. 6>The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 7 8## CaretStyle<sup>10+</sup> 9 10**Atomic service API**: This API can be used in atomic services since API version 11. 11 12**System capability**: SystemCapability.ArkUI.ArkUI.Full 13 14| Name| Type | Mandatory| Description| 15| ------ | ------------------------------------------ | ---- | -------- | 16| width | [Length](ts-types.md#length) | No | Caret size. It cannot be set in percentage.| 17| color | [ResourceColor](ts-types.md#resourcecolor) | No | Caret color.| 18 19## LayoutManager<sup>12+</sup> 20 21Implements a **LayoutManager** object. 22 23> **NOTE** 24> 25> After the text content is changed, you must wait for the layout to be completed before you can obtain the most up-to-date layout information. 26 27### Objects to Import 28The following uses the **Text** component as an example. 29``` 30controller: TextController = new TextController() 31let layoutManager: LayoutManager = this.controller.getLayoutManager(); 32``` 33 34### getLineCount 35 36getLineCount(): number 37 38Obtains the total number of lines in the component. 39 40**Atomic service API**: This API can be used in atomic services since API version 12. 41 42**System capability**: SystemCapability.ArkUI.ArkUI.Full 43 44**Return value** 45 46| Type | Description | 47| ------ | --------- | 48| number | Total number of lines in the component.| 49 50### getGlyphPositionAtCoordinate 51 52getGlyphPositionAtCoordinate(x: number, y: number): PositionWithAffinity 53 54Obtains the position of a glyph close to a given coordinate. 55 56**Atomic service API**: This API can be used in atomic services since API version 12. 57 58**System capability**: SystemCapability.ArkUI.ArkUI.Full 59 60**Parameters** 61 62| Name | Type | Mandatory | Description | 63| ------ | ------ | ---- | -------------------- | 64| x | number | Yes | X coordinate relative to the component, in px.| 65| y | number | Yes | Y coordinate relative to the component, in px.| 66 67**Return value** 68 69| Type | Description | 70| --------------------------------------------- | ----------- | 71| [PositionWithAffinity](#positionwithaffinity12) | Position of the glyph.| 72 73### getLineMetrics 74 75getLineMetrics(lineNumber: number): LineMetrics 76 77Obtains the metrics information of a specified line. 78 79**Atomic service API**: This API can be used in atomic services since API version 12. 80 81**System capability**: SystemCapability.ArkUI.ArkUI.Full 82 83**Parameters** 84 85| Name | Type | Mandatory | Description | 86| ------ | ------ | ---- | -------------------- | 87| lineNumber | number | Yes | Line number, starting at 0.| 88 89**Return value** 90 91| Type | Description | 92| ---------------------------------------- | -------- | 93| [LineMetrics](#linemetrics12) | Button("Line Metrics")| 94 95### getRectsForRange<sup>14+</sup> 96 97getRectsForRange(range: TextRange, widthStyle: RectWidthStyle, heightStyle: RectHeightStyle): Array\<TextBox> 98 99Obtains the drawing area information for characters or placeholders within a specified text range, based on the specified width and height of a rectangle. 100 101**Atomic service API**: This API can be used in atomic services since API version 14. 102 103**System capability**: SystemCapability.ArkUI.ArkUI.Full 104 105**Parameters** 106 107| Name | Type | Mandatory| Description | 108| ----------- | ----------------------------------- | ---- | ------------------------ | 109| range | [TextRange](#textrange12)| Yes | Text range for which to obtain the area information. | 110| widthStyle | [RectWidthStyle](#rectwidthstyle14) | Yes | Width of the rectangle.| 111| heightStyle | [RectHeightStyle](#rectheightstyle14) | Yes | Height of the rectangle.| 112 113**Return value** 114 115| Type | Description | 116| --------------------------- | ----------- | 117| Array\<[TextBox](#textbox14)> | Array holding the rectangles obtained.| 118 119## PositionWithAffinity<sup>12+</sup> 120 121Describes the position and affinity of a glyph. 122 123**Atomic service API**: This API can be used in atomic services since API version 12. 124 125**System capability**: SystemCapability.ArkUI.ArkUI.Full 126 127| Name | Type | Read Only| Optional| Description | 128| --------- | --------------------- | ---- | ---- | ------------------------ | 129| position | number | Yes | No | Index of the glyph relative to the paragraph. The value is an integer. | 130| affinity | [Affinity](#affinity12) | Yes | Yes | Affinity of the position. | 131 132## TextMenuItemId<sup>12+</sup> 133 134Provides the menu ID. 135 136**Atomic service API**: This API can be used in atomic services since API version 12. 137 138**System capability**: SystemCapability.ArkUI.ArkUI.Full 139 140### Attributes 141 142**System capability**: SystemCapability.ArkUI.ArkUI.Full 143 144| Name | Type | Read Only | Optional | Description | 145| ------------ |---------------------| ---- | ---- | ------ | 146| CUT | [TextMenuItemId](#textmenuitemid12) | Yes | Yes| Cut operation by default.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 147| COPY | [TextMenuItemId](#textmenuitemid12) | Yes | Yes | Copy operation by default.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 148| PASTE | [TextMenuItemId](#textmenuitemid12) | Yes | Yes | Paste operation by default.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 149| SELECT_ALL | [TextMenuItemId](#textmenuitemid12) | Yes | Yes | Select-all operation by default.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 150| COLLABORATION_SERVICE | [TextMenuItemId](#textmenuitemid12) | Yes | Yes | Collaboration service.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 151| CAMERA_INPUT | [TextMenuItemId](#textmenuitemid12) | Yes | Yes | Camera input<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 152| AI_WRITER<sup>13+</sup> | [TextMenuItemId](#textmenuitemid12) | Yes | Yes | Text enhancement features, such as polishing, summary extraction, and formatting, for selected text. This menu item requires large model capabilities to function.<br>**Atomic service API**: This API can be used in atomic services since API version 13.| 153 154### of 155 156static of(id: ResourceStr): TextMenuItemId 157 158Creates a **TextMenuItemId** object based on **id**. 159 160**Atomic service API**: This API can be used in atomic services since API version 12. 161 162**System capability**: SystemCapability.ArkUI.ArkUI.Full 163 164**Parameters** 165 166| Name | Type | Mandatory| Description | 167| ------- | --------------------------------- | ---- | ------------------------------------------------------------ | 168| id | [ResourceStr](ts-types.md#resourcestr) | Yes | Menu ID.| 169 170**Return value** 171 172| Type | Description | 173| ------- | --------------------------------- | 174| [TextMenuItemId](#textmenuitemid12) | **TextMenuItemId** object.| 175 176### equals 177 178equals(id: TextMenuItemId): boolean 179 180Checks whether this **TextMenuItemId** object is the same as another **TextMenuItemId** object. 181 182**Atomic service API**: This API can be used in atomic services since API version 12. 183 184**System capability**: SystemCapability.ArkUI.ArkUI.Full 185 186**Parameters** 187 188| Name | Type | Mandatory| Description | 189| ------- | --------------------------------- | ---- | ------------------------------------------------------------ | 190| id | [TextMenuItemId](#textmenuitemid12) | Yes | ID of the **TextMenuItemId** object to compare.| 191 192**Return value** 193 194| Type | Description | 195| ------- | --------------------------------- | 196| boolean | Whether the two **TextMenuItemId** objects are the same.| 197 198## TextMenuItem<sup>12+</sup> 199 200**Atomic service API**: This API can be used in atomic services since API version 12. 201 202**System capability**: SystemCapability.ArkUI.ArkUI.Full 203 204| Name | Type | Mandatory| Description | 205| ------- | --------------------------------- | ---- | --------------------------------- | 206| content | [ResourceStr](ts-types.md#resourcestr) | Yes | Menu name.| 207| icon | [ResourceStr](ts-types.md#resourcestr) | No | Menu icon.<br>Online images are not supported.| 208| id | [TextMenuItemId](#textmenuitemid12) | Yes | Menu ID.| 209 210## EditMenuOptions 211 212**Atomic service API**: This API can be used in atomic services since API version 12. 213 214**System capability**: SystemCapability.ArkUI.ArkUI.Full 215 216### onCreateMenu<sup>12+</sup> 217 218onCreateMenu(menuItems: Array\<TextMenuItem>): Array\<TextMenuItem> 219 220Creates a menu with the specified menu items. 221 222**Atomic service API**: This API can be used in atomic services since API version 12. 223 224**System capability**: SystemCapability.ArkUI.ArkUI.Full 225 226**Parameters** 227 228| Name | Type | Mandatory| Description | 229| ------- | --------------------------------- | ---- | --------------------------------- | 230| menuItems | Array\<[TextMenuItem](#textmenuitem12)> | Yes | Menu items.<br>**NOTE**<br>Changes to the name of the default menu item do not take effect.| 231 232**Return value** 233 234| Type | Description | 235| ------- | --------------------------------- | 236| Array\<[TextMenuItem](#textmenuitem12)> | Menu items set.<br>**NOTE**<br>The icon of the default menu item is not returned.| 237 238### onMenuItemClick<sup>12+</sup> 239 240onMenuItemClick(menuItem: TextMenuItem, range: TextRange): boolean 241 242Called when the specified menu item is clicked. 243 244**Atomic service API**: This API can be used in atomic services since API version 12. 245 246**System capability**: SystemCapability.ArkUI.ArkUI.Full 247 248**Parameters** 249 250| Name | Type | Mandatory| Description | 251| ------- | --------------------------------- | ---- | --------------------------------- | 252| menuItem | [TextMenuItem](#textmenuitem12) | Yes | Menu item.| 253| range | [TextRange](#textrange12) | Yes | Selected text.| 254 255**Return value** 256 257| Type | Description | 258| ------- | --------------------------------- | 259| boolean | Execution logic of the menu item.<br>Returns **true** if the default system logic is intercepted and only the custom logic is executed.<br>Returns **false** if the custom logic is executed before the default system logic.| 260 261## TextRange<sup>12+</sup> 262 263Defines the text range. 264 265**Atomic service API**: This API can be used in atomic services since API version 12. 266 267**System capability**: SystemCapability.ArkUI.ArkUI.Full 268 269### Attributes 270 271| Name| Type| Mandatory| Description| 272| -- | -- | -- | -- | 273| start | number | No| Start index.| 274| end | number | No| End index.| 275 276## EditableTextOnChangeCallback<sup>12+</sup> 277 278type EditableTextOnChangeCallback = (value: string, previewText?: PreviewText) => void 279 280Invoked when the input in the text box changes. 281 282**Atomic service API**: This API can be used in atomic services since API version 12. 283 284**System capability**: SystemCapability.ArkUI.ArkUI.Full 285 286**Parameters** 287 288| Name| Type| Mandatory| Description| 289| -- | -- | -- | -- | 290| value | string | Yes| Text displayed in the text box.| 291| previewText | [PreviewText](#previewtext12) | No| Information about the preview text, including its start position and text content.| 292 293## TextDataDetectorType<sup>11+</sup> 294 295**Atomic service API**: This API can be used in atomic services since API version 12. 296 297**System capability**: SystemCapability.ArkUI.ArkUI.Full 298 299| Name | Description | 300| ----- | -------------------------------------- | 301| PHONE_NUMBER | Phone number.| 302| URL | URL.| 303| EMAIL | Email address.| 304| ADDRESS | Address.| 305| DATE_TIME<sup>12+</sup> | Time.| 306 307## TextDeleteDirection<sup>12+</sup> 308 309Defines the direction for deleting text. 310 311**Atomic service API**: This API can be used in atomic services since API version 12. 312 313**System capability**: SystemCapability.ArkUI.ArkUI.Full 314 315| Name | Value | Description | 316| ------- | ---- | ---------------------------------- | 317| BACKWARD | 0 | Backward delete.| 318| FORWARD | 1 | Forward delete.| 319 320## MenuType<sup>13+</sup> 321 322Enumerates the menu types. 323 324**Atomic service API**: This API can be used in atomic services since API version 13. 325 326**System capability**: SystemCapability.ArkUI.ArkUI.Full 327 328| Name| Value| Description| 329| ------- | ---- | ------------------- | 330| SELECTION_MENU | 0 | Text selection menu.| 331| PREVIEW_MENU | 1 | Preview menu.| 332 333## InsertValue<sup>12+</sup> 334 335**Atomic service API**: This API can be used in atomic services since API version 12. 336 337**System capability**: SystemCapability.ArkUI.ArkUI.Full 338 339| Name | Type | Mandatory| Description | 340| ------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | 341| insertOffset | number | Yes | Position of the inserted text.| 342| insertValue | string | Yes | Content of the inserted text.| 343 344## DeleteValue<sup>12+</sup> 345 346**Atomic service API**: This API can be used in atomic services since API version 12. 347 348**System capability**: SystemCapability.ArkUI.ArkUI.Full 349 350| Name | Type | Mandatory| Description | 351| ------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | 352| deleteOffset | number | Yes | Position of the deleted text.| 353| direction | [TextDeleteDirection](#textdeletedirection12) | Yes | Direction for deleting the text.| 354| deleteValue | string | Yes | Content of the deleted text.| 355 356## TextDataDetectorConfig<sup>11+</sup> 357 358**Atomic service API**: This API can be used in atomic services since API version 12. 359 360**System capability**: SystemCapability.ArkUI.ArkUI.Full 361 362| Name| Type | Mandatory| Description | 363| ------ | -------- | ---- | ------------------------------------------- | 364| types | [TextDataDetectorType](ts-text-common.md#textdatadetectortype11)[] | Yes | Entity types for text recognition. Values **null** and **[]** indicate that all types of entities can be recognized.| 365| onDetectResultUpdate | (result: string) => void | No | Callback invoked when text recognition succeeds.<br>- **result**: text recognition result, in JSON format.| 366| color<sup>12+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Entity color when text recognition succeeds.<br>Default value: **'#ff0a59f7'**| 367| decoration<sup>12+</sup> | [DecorationStyleInterface](ts-universal-styled-string.md#decorationstyleinterface)| No | Style of the entity decorative line when text recognition succeeds.<br>Default value:<br>{<br> type: TextDecorationType.Underline,<br> color: same as the entity<br> style: TextDecorationStyle.SOLID <br>} | 368## PreviewText<sup>12+</sup> 369 370Preview text. 371 372**Atomic service API**: This API can be used in atomic services since API version 12. 373 374**System capability**: SystemCapability.ArkUI.ArkUI.Full 375 376| Name | Type | Mandatory| Description | 377| -------- | ------------------------------------------------ | ---- | -------------------------------------------------------- | 378| offset | number | Yes | Start position of the preview text.| 379| value | string | Yes | Content of the preview text. | 380 381## FontSettingOptions<sup>12+</sup> 382 383Defines the font settings, including smooth and continuous adjustments for the font weight for components in your application. 384 385**Widget capability**: This API can be used in ArkTS widgets since API version 12. 386 387**Atomic service API**: This API can be used in atomic services since API version 12. 388 389**System capability**: SystemCapability.ArkUI.ArkUI.Full 390 391| Name | Type | Mandatory| Description | 392| -------- | ------------------------------------------------ | ---- | -------------------------------------------------------- | 393| enableVariableFontWeight | boolean | No | Whether to support variable font weight adjustment.<br>Default value: **false**| 394 395## OnDidChangeCallback<sup>12+</sup> 396 397type OnDidChangeCallback = (rangeBefore: TextRange, rangeAfter: TextRange) => void 398 399Represents the callback invoked after text changes. 400 401**Atomic service API**: This API can be used in atomic services since API version 12. 402 403**System capability**: SystemCapability.ArkUI.ArkUI.Full 404 405**Parameters** 406 407| Name| Type| Mandatory| Description| 408| -- | -- | -- | -- | 409| rangeBefore | [TextRange](#textrange12) | Yes| Range of the text to be changed.| 410| rangeAfter | [TextRange](#textrange12) | Yes| Range of the text added.| 411 412## StyledStringChangedListener<sup>12+</sup> 413 414Defines the listener for changes of the styled string text content. 415 416**Atomic service API**: This API can be used in atomic services since API version 12. 417 418**System capability**: SystemCapability.ArkUI.ArkUI.Full 419 420| Name| Type| Mandatory| Description| 421| -- | -- | -- | -- | 422| onWillChange | Callback<[StyledStringChangeValue](ts-basic-components-richeditor.md#styledstringchangevalue12), boolean> | No| Callback invoked when text is about to change.| 423| onDidChange | [OnDidChangeCallback](#ondidchangecallback12) | No| Callback invoked when text is changed.| 424 425## StyledStringChangeValue<sup>12+</sup> 426 427Describes the text changes of the styled string. 428 429**Atomic service API**: This API can be used in atomic services since API version 12. 430 431**System capability**: SystemCapability.ArkUI.ArkUI.Full 432 433| Name| Type| Mandatory| Description| 434| -- | -- | -- | -- | 435| range | TextRange | Yes| Range of the styled string to be replaced in the original string.| 436| replacementString | [StyledString](ts-universal-styled-string.md#styledstring) | Yes| Styled string used for replacement.| 437| previewText | [StyledString](ts-universal-styled-string.md#styledstring) | No| Preview styled string.| 438 439## TextBaseController<sup>12+</sup> 440 441Defines a text selection controller. 442 443**Atomic service API**: This API can be used in atomic services since API version 12. 444 445**System capability**: SystemCapability.ArkUI.ArkUI.Full 446 447### setSelection<sup>12+</sup> 448 449setSelection(selectionStart: number, selectionEnd: number, options?: SelectionOptions): void 450 451Sets the range of content selection. The selected content is highlighted. 452 453If both **selectionStart** and **selectionEnd** are set to **-1**, the entire content is selected. 454 455The component must be focused for the API call to have effect. 456 457Since API version 12, on 2-in-1 devices, regardless of the value of **options**, calling the **setSelection** API will not display a menu; if a menu is already open, calling the API will close it. 458 459On non-2-in-1 devices, when **options** is set to **MenuPolicy.DEFAULT**, the following rules apply after the API is called: 460 4611. If the component has a menu with a selection handle, the menu remains open and is relocated according to the selection. 462 4632. If the component has a menu without a selection handle, the menu remains open and its position remains unchanged. 464 4653. If there is no menu open, no menu will appear after the selection. 466 467**Atomic service API**: This API can be used in atomic services since API version 12. 468 469**System capability**: SystemCapability.ArkUI.ArkUI.Full 470 471**Parameters** 472 473| Name | Type | Mandatory | Description | 474| -------------- | ------ | ---- | ------- | 475| selectionStart | number | Yes | Start position of the selection.| 476| selectionEnd | number | Yes | End position of the selection.| 477| options<sup>12+</sup> | [SelectionOptions](ts-types.md#selectionoptions12) | No | Configuration of options.| 478 479### closeSelectionMenu<sup>12+</sup> 480 481closeSelectionMenu(): void 482 483Closes the custom or default text selection menu. 484 485**Atomic service API**: This API can be used in atomic services since API version 12. 486 487**System capability**: SystemCapability.ArkUI.ArkUI.Full 488 489### getLayoutManager<sup>12+</sup> 490 491getLayoutManager(): LayoutManager 492 493Obtains a **LayoutManager** object. 494 495**Atomic service API**: This API can be used in atomic services since API version 12. 496 497**System capability**: SystemCapability.ArkUI.ArkUI.Full 498 499**Return value** 500 501| Type | Description | 502| ---------------------------------------- | ------- | 503| [LayoutManager](ts-text-common.md#layoutmanager12) | Implements a **LayoutManager** object.| 504 505## TextEditControllerEx<sup>12+</sup> 506 507Implements an extended text editing controller. 508 509Inherits [TextBaseController](#textbasecontroller12). 510 511**Atomic service API**: This API can be used in atomic services since API version 12. 512 513**System capability**: SystemCapability.ArkUI.ArkUI.Full 514 515### isEditing<sup>12+</sup> 516 517isEditing(): boolean 518 519Obtains the editing status of the rich text. 520 521**Atomic service API**: This API can be used in atomic services since API version 12. 522 523**System capability**: SystemCapability.ArkUI.ArkUI.Full 524 525**Return value** 526 527| Type | Description | 528| ------- | ----------------------------- | 529| boolean | Editing status of the rich text. **true** means that the text is in editable state, and **false** means the opposite.| 530 531### stopEditing<sup>12+</sup> 532 533stopEditing(): void 534 535Stops editing. 536 537**Atomic service API**: This API can be used in atomic services since API version 12. 538 539**System capability**: SystemCapability.ArkUI.ArkUI.Full 540 541### getCaretOffset<sup>12+</sup> 542 543getCaretOffset(): number 544 545Obtains the current position of the cursor. 546 547**Atomic service API**: This API can be used in atomic services since API version 12. 548 549**System capability**: SystemCapability.ArkUI.ArkUI.Full 550 551**Return value** 552 553| Type | Description | 554| ------ | --------- | 555| number | Position of the cursor.| 556 557### setCaretOffset<sup>12+</sup> 558 559setCaretOffset(offset: number): boolean 560 561Sets the cursor offset. 562 563**Atomic service API**: This API can be used in atomic services since API version 12. 564 565**System capability**: SystemCapability.ArkUI.ArkUI.Full 566 567**Parameters** 568 569| Name | Type | Mandatory | Description | 570| ------ | ------ | ---- | -------------------- | 571| offset | number | Yes | Offset of the cursor. If the offset is outside the range of all content, the setting fails.| 572 573**Return value** 574 575| Type | Description | 576| ------- | --------- | 577| boolean | Whether the cursor is set successfully.| 578 579### getPreviewText<sup>12+</sup> 580 581getPreviewText?(): PreviewText 582 583Obtains the preview text. 584 585**Atomic service API**: This API can be used in atomic services since API version 12. 586 587**System capability**: SystemCapability.ArkUI.ArkUI.Full 588 589**Return value** 590 591| Type | Description | 592| ---------------------------------------- | ------- | 593| [PreviewText](#previewtext12) | Preview text.|. 594 595## StyledStringController<sup>12+</sup> 596 597Defines a styled string controller. 598 599**Atomic service API**: This API can be used in atomic services since API version 12. 600 601**System capability**: SystemCapability.ArkUI.ArkUI.Full 602 603### setStyledString<sup>12+</sup> 604 605setStyledString(styledString: StyledString): void 606 607Sets the styled string displayed in the rich text component. 608 609**Atomic service API**: This API can be used in atomic services since API version 12. 610 611**System capability**: SystemCapability.ArkUI.ArkUI.Full 612 613**Parameters** 614 615| Name | Type | Mandatory | Description | 616| ----- | ------ | ---- | ------------------- | 617| styledString | [StyledString](ts-universal-styled-string.md#styledstring) | Yes | Styled string to set.<br>**NOTE**<br>The child class [MutableStyledString](ts-universal-styled-string.md#mutablestyledstring) of **StyledString** can also serve as the argument.| 618 619### getStyledString<sup>12+</sup> 620 621getStyledString(): MutableStyledString; 622 623Obtains the styled string displayed in the rich text component. 624 625**Atomic service API**: This API can be used in atomic services since API version 12. 626 627**System capability**: SystemCapability.ArkUI.ArkUI.Full 628 629**Return value** 630 631| Type | Description | 632| ------- | ----------------------------- | 633| [MutableStyledString](ts-universal-styled-string.md#mutablestyledstring) | Styled string displayed in the rich text component.| 634 635## DecorationStyleResult<sup>12+</sup> 636 637Provides the text decorative line information returned by the backend. 638 639**Atomic service API**: This API can be used in atomic services since API version 12. 640 641**System capability**: SystemCapability.ArkUI.ArkUI.Full 642 643| Name | Type | Mandatory| Description | 644| ------- | --------------------------------- | ---- | --------------------------------- | 645| type | [TextDecorationType](ts-appendix-enums.md#textdecorationtype) | Yes | Type of the text decorative line.| 646| color | [ResourceColor](ts-types.md#resourcecolor) | Yes | Color of the text decorative line.| 647| style | [TextDecorationStyle](ts-appendix-enums.md#textdecorationstyle12) | No | Style of the text decorative line.| 648 649## LineMetrics<sup>12+</sup> 650 651type LineMetrics = LineMetrics 652 653Describes the measurement information of a single line of text in the text layout. 654 655**Atomic service API**: This API can be used in atomic services since API version 12. 656 657**System capability**: SystemCapability.ArkUI.ArkUI.Full 658 659| Type | Description | 660| --------------------------------- | --------------------------------- | 661| [LineMetrics](../../apis-arkgraphics2d/js-apis-graphics-text.md#linemetrics) | Measurement information of a single line of text in the text layout.| 662 663## Affinity<sup>12+</sup> 664 665type Affinity = Affinity 666 667Enumerates the affinity modes. 668 669**Atomic service API**: This API can be used in atomic services since API version 12. 670 671**System capability**: SystemCapability.ArkUI.ArkUI.Full 672 673| Type | Description | 674| --------------------------------- | --------------------------------- | 675| [Affinity](../../apis-arkgraphics2d/js-apis-graphics-text.md#affinity) | Affinity mode enum.| 676 677## TextBox<sup>14+</sup> 678 679type TextBox = TextBox 680 681Describes the rectangle that holds the text. 682 683**Atomic service API**: This API can be used in atomic services since API version 14. 684 685**System capability**: SystemCapability.ArkUI.ArkUI.Full 686 687| Type | Description | 688| --------------------------------- | --------------------------------- | 689| [TextBox](../../apis-arkgraphics2d/js-apis-graphics-text.md#textbox) | Rectangle that holds the text.| 690 691## RectHeightStyle<sup>14+</sup> 692 693type RectHeightStyle = RectHeightStyle 694 695Enumerates the rectangle height styles. 696 697**Atomic service API**: This API can be used in atomic services since API version 14. 698 699**System capability**: SystemCapability.ArkUI.ArkUI.Full 700 701| Type | Description | 702| --------------------------------- | --------------------------------- | 703| [RectHeightStyle](../../apis-arkgraphics2d/js-apis-graphics-text.md#rectheightstyle) | Rectangle height style enum.| 704 705## RectWidthStyle<sup>14+</sup> 706 707type RectWidthStyle = RectWidthStyle 708 709Enumerates the rectangle width styles. 710 711**Atomic service API**: This API can be used in atomic services since API version 14. 712 713**System capability**: SystemCapability.ArkUI.ArkUI.Full 714 715| Type | Description | 716| --------------------------------- | --------------------------------- | 717| [RectWidthStyle](../../apis-arkgraphics2d/js-apis-graphics-text.md#rectwidthstyle) | Rectangle width style enum.| 718