0

Is it possible to preload @font-face files for later use?

Ideally I'd like to:

  • Detect the correct font file for the browser (woff, eot, ttf, etc) and preload it
  • Detect when the font has been loaded, to trigger further events

This will form part of a preloader tool that will calculate progress and block page interaction. This generally rules out browser based solutions such as prefetch.

Matt Stone
  • 3,705
  • 4
  • 23
  • 40
  • This question may help:[http://stackoverflow.com/questions/2756575/drawing-text-to-canvas-with-font-face-does-not-work-at-the-first-time](http://stackoverflow.com/questions/2756575/drawing-text-to-canvas-with-font-face-does-not-work-at-the-first-time) – jiguang Oct 10 '12 at 03:21
  • Checking '@font-face' load: http://stackoverflow.com/questions/12312323/how-to-know-if-a-font-font-face-has-already-been-loaded/12316349#12316349 – Patrick Oct 16 '12 at 09:42

1 Answers1

-1

You can dynamically add a style element to the head, and have your font-face declaration in that.

Then, you can dynamically add a class to any element, to which you can apply the font-family value for your font.

No need to play with preload.

daveyfaherty
  • 4,585
  • 2
  • 27
  • 42
  • I _want_ to play with preload. font-face files can be quite large, and I'd like to know when the file has finished downloading. – Matt Stone Oct 17 '12 at 03:55