measureText - method of the CanvasCtx object
Description:
Returns object that contains the width of the specified text (in pixels).
Syntax:
Object measureText(Long text)
Example:
The
ctx variable represents the drawing canvas (
CanvasCtx). The setup is done on the "
Draw" tab at the beginning of the script of drawing event
onDraw as follows:
var ctx =
pEvent.
GetCtx(1);
JavaScriptSelect and copy to clipboard
ctx.font = "30px Arial";
var txt = "Promotic";
ctx.fillText("width:" + ctx.measureText(txt), 10, 50);
ctx.fillText(txt, 10, 100);