font-picker-react icon indicating copy to clipboard operation
font-picker-react copied to clipboard

onLoad event

Open nuthinking opened this issue 4 years ago • 3 comments

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 avatar Jul 04 '20 13:07 nuthinking

Should FontFaceObserver be used?

nuthinking avatar Jul 04 '20 14:07 nuthinking

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`);
      });
    }
  }

nuthinking avatar Jul 04 '20 15:07 nuthinking

it's not working for me lol

willyou avatar Oct 04 '20 02:10 willyou