jimp-dev / jimp-dev/jimp

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

Open
#1,339 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14.7k
Forks
777
PR merge metrics
No merged PRs in 30d

Description

# 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)

```js
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
```shell
ReferenceError: fetch is not defined
```

- Jimp Version: 1.4.0
- Operating System: mac OS
- Node version: 20

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.