I’m printing text to a canvas in a pretty straight forward way:
var ctx = canvas.getContext('2d');
ctx.font = "10pt Courier";
ctx.fillText("Hello World", 100, 100);
But how can I change the text to bold, italic or both? Any suggestions to fix that simple example?
From the MDN documentation on
CanvasRenderingContext2D.font:So, that means any of the following will work:
Here are a couple of additional resources for more information: