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

Jimp Browser with Web Workers issue when loading font #289

Closed
JOscarEduardo opened this issue Jun 16, 2017 · 3 comments
Closed

Jimp Browser with Web Workers issue when loading font #289

JOscarEduardo opened this issue Jun 16, 2017 · 3 comments
Labels
bug there is a bug in the way jimp behaves help wanted reproduction needed

Comments

@JOscarEduardo
Copy link

Hi, guys!

Jimp is amazing! I am using it in the server and also in the browser. Recently I decided to use it inside of a web worker. However, when I do that, the Jimp.loadFont fails when trying to load a font. The message is:

Error: error parsing font document is not defined
    at Object.callback (jimp.js:4657)
    at cbOnce (jimp.js:8445)
    at loadFunc (jimp.js:8449)
    at XMLHttpRequest.readystatechange (jimp.js:8445)

I noticed, in the network pane of chrome console, that the .fnt file is loading correctly. However, the .png file doesn't even appear in the network pane.

I used the same calls and paths (native fonts) that are currently in use and working properly without the Web Worker.

Any hints?

Thanks!

Oscar

@hipstersmoothie
Copy link
Collaborator

@JOscarEduardo can you provide me some sample code?

@hipstersmoothie hipstersmoothie added bug there is a bug in the way jimp behaves and removed bug-issue labels Aug 26, 2018
@hipstersmoothie
Copy link
Collaborator

Closing as there was never a repro

@av01d
Copy link

av01d commented Mar 20, 2024

I am confused... was this issue 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug there is a bug in the way jimp behaves help wanted reproduction needed
Projects
None yet
Development

No branches or pull requests

3 participants