Afaik,您只能为WHOLE画布设置字体。
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.font = "30px Arial"
Run Code Online (Sandbox Code Playgroud)
我想说,text1为“ 30px Arial”,text2为“ 10px Arial”。这可能吗?
是的,它是可能的:
//first text
ctx.font = "30px Arial";
ctx.fillText("Hello World",10,50);
//second text
ctx.font = "20px Arial";
ctx.fillText("Bell World",50,100);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
801 次 |
| 最近记录: |