Skip to content Skip to sidebar Skip to footer

How Do I Wait For First Canvas-repaint Until @font-face-font Is Loaded?

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

Solution 1:

well, you could try this,

$.get('font/url.ttf',function(){
   // do canvas codes.... cause font is loaded...
});

Solution 2:

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.

Post a Comment for "How Do I Wait For First Canvas-repaint Until @font-face-font Is Loaded?"