Draws text to the canvas.
The text is drawn starting at coordinates (x
, y
). If maxWidth
is provided and the text
is computed to be wider than maxWidth
, then the drawn text is scaled down horizontally to fit.
The text uses the current CanvasRenderingContext2D.font property for font options, such as typeface and size, and the current CanvasRenderingContext2D.fillStyle for style options such as color. The current CanvasRenderingContext2D.textAlign and CanvasRenderingContext2D.textBaseLine
properties are also applied to the drawn text.
void fillText(String text, num x, num y, [num maxWidth]) { if (maxWidth != null) { JS('void', '#.fillText(#, #, #, #)', this, text, x, y, maxWidth); } else { JS('void', '#.fillText(#, #, #)', this, text, x, y); } }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-html/CanvasRenderingContext2D/fillText.html