Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Fail load detection when url from google includes several weights #20

Open
nobuti opened this issue May 14, 2015 · 2 comments
Open

Fail load detection when url from google includes several weights #20

nobuti opened this issue May 14, 2015 · 2 comments

Comments

@nobuti
Copy link

nobuti commented May 14, 2015

I'm trying to apply these scenario from @bevacqua performance workshop:
https://github.com/bevacqua/perfschool/tree/master/exercises/using_a_font_loader

That solution works like a charm... if the url has the defaults weights. I'm trying without success apply the same logic when working with a subset of fonts like these: https://fonts.googleapis.com/css?family=Lato:700,900|Bitter:400italic.

With this script:

  var ffol = global.FontFaceOnload;
  var html = document.documentElement;

  function watch (family) {
    function loaded () {
      html.className += ' ok-' + family.toLowerCase();
    }

    function notLoaded() {
      console.error("Error loading " + family + " font.");
    }

    ffol(family, {
      timeout: 10000,
      success: loaded,
      error: notLoaded 
    });
  }

  watch('Lato');
  watch('Bitter');

the fail callback is always thrown. Am I missing something?

@nobuti
Copy link
Author

nobuti commented May 15, 2015

Not completely sure, but maybe it's related (or it's the same issue) to #13.

@zrothauser
Copy link

@nobuti, try specifying a weight and style in the options, if you're not loading the 400/normal version of the font. I ran into this issue today, and specifying a weight of 700 was necessary for one where I didn't need the 400 weight.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants