var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
//往文字上描边
ctx.lineWidth = 2;
ctx.font = "bold 100px serif";
ctx.fillStyle = 'red';
ctx.fillText("Hello world", 50, 200);
ctx.font = "bold 100px serif";
ctx.strokeStyle = 'blue';
ctx.strokeText("Hello world", 50, 200);
//往文字外描边
ctx.lineWidth = 2;
ctx.font = "bold 100px serif";
ctx.strokeStyle = 'blue';
ctx.strokeText("Hello world", 50, 400);
ctx.font = "bold 100px serif";
ctx.fillStyle = 'red';
ctx.fillText("Hello world", 50, 400);
样式: