2

So I got this font I want to in a <canvas> Element. Chrome seems to load the font on first use, and window.onload(); is called before the font is loaded.

How can I ensure a @font-face font being loaded? Or hook to an event thats called if?

There seems to be a tool for that Google/Typekit WebFont Loader. Great. So how do they do it? I'd like to do it in my own code.

axkibe
  • 2,787
  • 4
  • 19
  • 13
  • have you looked into http://stackoverflow.com/questions/3394433/how-do-i-wait-for-first-canvas-repaint-until-font-face-font-is-loaded ? – Manticore May 29 '12 at 10:29

1 Answers1

2

If you're still interested in this (or anyone else stumbles across this question), the WebFont Loader API's source is currently on GitHub:

https://github.com/typekit/webfontloader

Looks like most of the interesting stuff regarding checking if fonts are active occurs in src/core/fontwatcher.js and src/core/fontwatchrunner.js. Seeing it supports multiple providers, you may want to also look at a specific provider's implementations to see how the objects are used (e.g. src/google/*.js).