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

Use fetch to load fonts in load Font, but it fails in the node environment #1339

Open
Tzyito opened this issue Sep 11, 2024 · 2 comments
Open

Comments

@Tzyito
Copy link

Tzyito commented Sep 11, 2024

Expected Behavior

Normal loading font

Current Behavior

When I was writing a Raycast extension, I used Jimp to draw text onto an image. I encountered an error: fetch is undefined, because loadFont uses the fetch function, which does not exist in the Node environment

Failure Information (for bugs)

const SANS_32_BLACK = await fs.readFile(path.join(environment.assetsPath, 'fonts/open-sans-16-black.fnt'), {
  encoding: 'utf-8'
})
const font = await loadFont(SANS_32_BLACK)

and get an error

ReferenceError: fetch is not defined
  • Jimp Version: 1.4.0
  • Operating System: mac OS
  • Node version: 20
@hipstersmoothie
Copy link
Collaborator

Are yo sure you're using node 18? it's globally available since node 18 and that's our minimum supported version

https://nodejs.org/en/blog/announcements/v18-release-announce

@Tzyito
Copy link
Author

Tzyito commented Sep 30, 2024

my node version is 20,and i use jimp in raycast. Maybe raycast can't use fetch?

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