Canvas 除了 fillText 可填滿文字外,也能使用 strokeText() 繪製只有外框的空心文字。這適合標題、海報或特殊視覺效果。
const c = document.getElementById('myCanvas');
const ctx = c.getContext('2d');
ctx.font = '30px Arial';
ctx.strokeText('Hello World', 10, 50);
可透過 lineWidth 調整外框粗細,也可用 strokeStyle 設定線條顏色。若要同時有填色與外框,可先 fillText 再 strokeText。