Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onLoad event #38

Open
nuthinking opened this issue Jul 4, 2020 · 3 comments
Open

onLoad event #38

nuthinking opened this issue Jul 4, 2020 · 3 comments

Comments

@nuthinking
Copy link

Is there a way to know when the new selected font has been loaded? In case of using a canvas for the rendering. Thanks!

@nuthinking
Copy link
Author

Should FontFaceObserver be used?

@nuthinking
Copy link
Author

This seems to work:

componentDidUpdate(prevProps, prevState) {
    if (prevState.activeFontFamily !== this.state.activeFontFamily) {
      const font = new FontFaceObserver(this.state.activeFontFamily);
      font.load().then(() => {
        console.log(`${this.state.activeFontFamily} has loaded`);
      }, () => {
        console.log(`${this.state.activeFontFamily} is not available`);
      });
    }
  }

@willyou
Copy link

willyou commented Oct 4, 2020

it's not working for me lol

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

No branches or pull requests

2 participants