CanvasContext.measureText
Measure the size of the text, current only the witch is returned, and it is a synchronous interface
Parameters
It is Object type.
Property | Type | Required | Description |
text | String | Yes | The text that needs to be measured. |
Return Value
Property | Type | Description |
width | Number | The width of the text. |
Sample Code
copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')
ctx.font = 'italic bold 50px cursive'
const { width } = ctx.measureText('hello world')
console.log(width)