typekit / webfontloader

Web Font Loader gives you added control when using linked fonts via @font-face.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to catch 404 error ?

impestdev opened this issue · comments

FYI for anyone else looking I got this working with this:

  const fetchFont = async (fontName: string) => {
    try {
      const promise = new Promise((resolve, reject) => {
        WebFont.load({
          google: { families: [fontName] },
          active: () => resolve("true"),
          inactive: () => reject("404"),
        })
      })
      await promise
      .....
    } catch (err) {
      console.log("HAS ERR", err)
      .....
    }
  }