admin管理员组文章数量:1391951
I have a HTML5-canvas and write text with context.fillText(...);
using a @font-face-font.
Displaying the page with Firefox (3.6) I have the problem, that on the first paint of the canvas the font is not downloaded yet so the text will be displayed with a standard-font.
I found a 'solution' here but it does not work, because the font is only used in the canvas and the canvas is loaded and displayed with ajax using jQuery.
Is there any better solution than trying to use a timeout setTimeout(repaintCanvas, 500);
?
I have a HTML5-canvas and write text with context.fillText(...);
using a @font-face-font.
Displaying the page with Firefox (3.6) I have the problem, that on the first paint of the canvas the font is not downloaded yet so the text will be displayed with a standard-font.
I found a 'solution' here but it does not work, because the font is only used in the canvas and the canvas is loaded and displayed with ajax using jQuery.
Is there any better solution than trying to use a timeout setTimeout(repaintCanvas, 500);
?
- See stackoverflow./questions/2756575/… – a paid nerd Commented Nov 22, 2011 at 7:50
2 Answers
Reset to default 4well, you could try this,
$.get('font/url.ttf',function(){
// do canvas codes.... cause font is loaded...
});
I think I found a solution with the help of Reigel's answer:
$.get('font/url.ttf', function() {
// do canvas codes.... cause font is loaded...
});
Additionally use the font via font-family: 'fontfacename';
for the canvas' parent-element.
Could be that the font is loaded twice, don't know. But without the second load it won't be displayed right.
本文标签: javascriptHow do I wait for first canvasrepaint until fontfacefont is loadedStack Overflow
版权声明:本文标题:javascript - How do I wait for first canvas-repaint until @font-face-font is loaded? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744735527a2622304.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论