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
2012/09/29
3:52 UTC
Read the original article
Hit count: 227
JavaScript
|html5
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?
Edit -
I'll expand the question, because I hadn't taken the first comment into account. What would the proper method of handling this be in the case that a user has disabled custom fonts?
© Game Development or respective owner