我一直在尝试使用<canvas>标签绘制简单的图表和图表,到目前为止,它很容易使用.我想到了一个问题.我无法弄清楚如何<canvas>在Safari中绘制文本.在Firefox 3.0中,我可以这样做:
Chart.prototype.drawTextCentered = function(context, text, x, y, font, color) {
if (context.mozDrawText) {
context.save();
context.fillStyle = color;
context.mozTextStyle = font;
x -= 0.5 * context.mozMeasureText(text);
context.translate(x, y);
context.mozDrawText(text);
context.restore();
}
}
Run Code Online (Sandbox Code Playgroud)
我已经看到fillText()了Apple的Safari文档中的方法,但它似乎在Safari 3.2中不受支持.这只是目前缺失的东西,还是一些保密的秘密?