HTML and CSS Reference
In-Depth Information
To set the font style (font face, size, etc.), use the font property:
mycontext. font = "25pt Arial";
Now, simply call the appropriate text command:
mycontext. fillText ("Hello World", 0, 25);
mycontext. strokeText ("Hello World", 0, 75);
The result of this code snippet is shown in Figure 9-13 .
Figure 9-13. Filled and stroked text
The fillText(...) and strokeText(...) commands use the font styling specified in the
font property. The available settings (font face, style, size, etc.) are defined to be the
same as what would be available to CSS font style rules. The colors used are, of course,
controlled by the fillStyle and strokeStyle properties, respectively. The same goes
for the stroke line width.
See Also
For more on drawing text on a canvas , see
_using_a_canvas .
Search WWH ::

Custom Search