提交 f2ef9e1e 编写于 作者: E ester.zhou

Add doc (15817)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 266f0426
......@@ -125,7 +125,20 @@
- [@ohos.notification (Notification) (To Be Deprecated Soon)](js-apis-notification.md)
- application
- [EventHub](js-apis-inner-application-eventHub.md)
- commonEvent
- [CommonEventData](js-apis-inner-commonEvent-commonEventData.md)
- [CommonEventPublishData](js-apis-inner-commonEvent-commonEventPublishData.md)
- [CommonEventSubscriber](js-apis-inner-commonEvent-commonEventSubscriber.md)
- [CommonEventSubscribeInfo](js-apis-inner-commonEvent-commonEventSubscribeInfo.md)
- notification
- [NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)
- [NotificationCommonDef](js-apis-inner-notification-notificationCommonDef.md)
- [NotificationContent](js-apis-inner-notification-notificationContent.md)
- [NotificationFlags](js-apis-inner-notification-notificationFlags.md)
- [NotificationRequest](js-apis-inner-notification-notificationRequest.md)
- [NotificationSlot](js-apis-inner-notification-notificationSlot.md)
- [NotificationTemplate](js-apis-inner-notification-notificationTemplate.md)
- [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md)
- Bundle Management
- [@ohos.bundle.appControl (appControl)](js-apis-appControl.md)
- [@ohos.bundle.bundleManager (bundleManager)](js-apis-bundleManager.md)
......@@ -156,8 +169,10 @@
- [@ohos.curves (Interpolation Calculation)](js-apis-curve.md)
- [@ohos.matrix4 (Matrix Transformation)](js-apis-matrix4.md)
- [@ohos.mediaquery (Media Query)](js-apis-mediaquery.md)
- [@ohos.pluginComponent (PluginComponentManager)](js-apis-plugincomponent.md)
- [@ohos.promptAction (Prompt)](js-apis-promptAction.md)
- [@ohos.router (Page Routing)](js-apis-router.md)
- [@ohos.measure (Text Measurement)](js-apis-measure.md)
- Graphics
- [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md)
......@@ -295,7 +310,7 @@
- [console (Log)](js-apis-logs.md)
- [Timer](js-apis-timer.md)
- application
- [AccessibilityExtensionContext](js-apis-inner-application-accessibilityExtensionContext.md)
- [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md)
- imf
- [InputMethodCommon](js-apis-inputmethod-InputMethodCommon.md)
......
# AccessibilityExtensionContext
# AccessibilityExtensionContext (Accessibility Extension Context)
The **AccessibilityExtensionContext** module, inherited from **ExtensionContext**, provides context for **Accessibility Extension** abilities.
......
# @ohos.measure (Text Measurement)
The **measure** module provides APIs for measuring text metrics, such as text height and width.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import measure from '@ohos.measure'
```
## measure.measureText
measureText(options: MeasureOptions): double
Measures the width of the given single-line text.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | --------- |
| options | [MeasureOptions](#measureoptions) | Yes | Information about the measured text.|
**Return value**
| Type | Description |
| ------------ | --------- |
| double | Text width.<br>The unit is px.|
**Example**
```ts
import measure from '@ohos.measure'
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
@State textWidth : number = measure.measureText({
textContent: "Hello word",
fontSize: '50px'
})
build() {
Row() {
Column() {
Text("The width of 'Hello World': " + this.textWidth)
}
.width('100%')
}
.height('100%')
}
}
```
## MeasureOptions
Provides attributes of the measured text.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory| Description |
| -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- |
| textContent | string | Yes | Content of the measured text. |
| fontSize | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Font size of the measured text. If the value is of the number type, the unit fp is used.<br>Default value: **16fp**<br>**NOTE**<br>The value cannot be a percentage. |
| fontStyle | number \| [FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | No | Font style of the measured text.<br>Default value: **FontStyle.Normal** |
| fontWeight | number \| string \| [FontWeight](../arkui-ts/ts-appendix-enums.md#fontweight) | No | Font width of the measured text. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a heavier font weight. The string type supports only the string of the number type, for example, **400**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.<br>Default value: **FontWeight.Normal**|
| fontFamily | string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Font family of the measured text. Default value: **'HarmonyOS Sans'**<br>Only the default font is supported.|
| letterSpacing | number \| string | No | Letter spacing of the measured text.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册