# CanvasContext.measureText(string text)

Measures text width

## Support

App capability | Android | iOS | PC | Harmony | Preview
---|---|---|---|---|---
Gadget | V3.9.0+ | V3.9.0+ | V3.9.0+ | V7.35.0+ | Preview
Web app | **X** | **X** | **X** | **X** | /

## Input

Name | Data type | Required | Default value | Description
---|---|---|---|---
text | string | Yes | &nbsp; | Text to be measured

## Output

Return value:

Name | Data type | Description
---|---|---
width | number | Text width

##  Sample code

```javascript
ctx.font = "italic bold 20px cursive";
const metrics = ctx.measureText("Hello Block");
console.log("MeasureText Result:", metrics.width);
```
