HTML5 - check if font has loaded

Posted by espais on Game Development See other posts from Game Development or by espais
Published on 2011-01-10T16:35:03Z Indexed on 2011/01/10 16:59 UTC
Read the original article Hit count: 248

Filed under:
|

At present I load my font for my game in with @font-face

For instance:

@font-face {
    font-family: 'Orbitron';
    src: url('res/orbitron-medium.ttf');
}

and then reference it throughout my JS implementation as such:

ctx.font = "12pt Orbitron";

where ctx is my 2d context from the canvas.

However, I notice a certain lag time while the font is downloaded to the user. Is there a way I can use a default font until it is loaded in?

© Game Development or respective owner

Related posts about JavaScript

Related posts about html5