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

Cannot load fonts in Web Worker #1286

Open
av01d opened this issue Mar 20, 2024 · 0 comments
Open

Cannot load fonts in Web Worker #1286

av01d opened this issue Mar 20, 2024 · 0 comments
Labels
documentation Changes only affect the documentation

Comments

@av01d
Copy link

av01d commented Mar 20, 2024

I am confused... was issue #289 ever considered? Using fonts in a WebWorker (still) does not work.
Example worker:

importScripts('./jimp.js');

(async () => {

  const font = await Jimp.loadFont('fonts/open-sans/open-sans-32-black/open-sans-32-black.fnt');

  self.addEventListener('message', e => {
    Jimp.read(e.data).then((img) => {
      img
      .print(font, 10, 10, "Hello World!")
      .getBase64(Jimp.AUTO, (err, src) => {
        if (err) throw err;
        self.postMessage(src);
      });
    });
  });

})();

The following error is thrown:

jimp.js:2 Uncaught (in promise) Error: error parsing font document is not defined

Using latest version of jimp (0.22.12)

Originally posted by @av01d in #289 (comment)

@hipstersmoothie hipstersmoothie added the documentation Changes only affect the documentation label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Changes only affect the documentation
Projects
None yet
Development

No branches or pull requests

2 participants