有没有一种方法能够只改变画布上下文的字体大小,而不必知道或编写字体族?
注意:
var ctx = document.getElementById("canvas").getContext("2d");
ctx.font = '20px Arial'; //Need to speficy both size and family...
注意:
ctx.fontSize = '12px'; //doesn't exist so won't work...
ctx.style.fontSize = '20 px' //doesn't exist so won't work...
//we are changing the ctx, not the canvas itself
另外注意:我可以做一些事情,比如检测'px'出现的位置,去掉'px'前面的内容并替换为我的字体大小。但如果有更简单的方法,我希望使用更简单的方法。