From the MDN documentation on CanvasRenderingContext2D.font:
The
CanvasRenderingContext2D.fontproperty of the Canvas 2D API specifies the current text style to use when drawing text. This string uses the same syntax as the CSS font specifier.
So, that means any of the following will work:
ctx.font = "italic 10pt Courier";
ctx.font = "bold 10pt Courier";
ctx.font = "italic bold 10pt Courier";
Here are a couple of additional resources for more information:
- Dive into HTML5
- HTML5 canvas – the basics