开发者

Drawing text in a canvas

I need to draw text in a canvas, but the current fillText implementation overcomplicates a lot of features that I need (like being able to draw mu开发者_开发技巧ltiple lines).

Because I need to copy the pixels from the canvas later, it must be drawn in the canvas, it can't be a span element over the canvas.

Being able to make it editable is a plus, but not required.

Is there any library that provides advanced features to draw text in a canvas? (It must work at least on IE9, Firefox, Chrome and Opera)


I only know of the FLOT Canvas Text plugin for jquery.

But if I were you I'd still do it with a <span> because it would then be Search Engine friendly. You can easily get the text of a span (or most) elements using element.innerHTML or element.innerText depending on the object. then you can process/pass that. e.g. for a span such as

<span id="myspan"> lorem ipsum </span>

I can say

spanText = document.getElementById("myspan").innerText;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜