Automattic / Automattic/node-canvas

Failed to use registered font with SvelteKit app on Node server

Open
#2,361 1 comment 0 reactions 0 assignees View on GitHub
Text & Fonts
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

Hi, I have a trouble with getting the fonts to work on production server. Everything works locally (MacOS, 2020 M1 running on Sonoma 14.1.1), but not on Node server.

This is the `registerFont` section of the code:
```
registerFont(path.resolve("./vidGenAssets/neue.otf"), { family: 'Neue Machina Regular' });
registerFont(path.resolve("./vidGenAssets/karla.ttf"), { family: 'Karla Regular' });
const canvas = new Canvas(w, h);
```

This is how I use them: `context.font = "40px 'Neue Machina Regular'";` or `context.font = "40px 'Karla Regular'";`

I am pretty sure the code can access the fonts on the server, because I've tried to delete them and run the script again. This ended up throwing a 404 error, as it could not find the files.

local and server `npm list` looks exactly the same
```
├── @playwright/test@1.42.1
├── @sveltejs/adapter-node@1.3.1
├── @sveltejs/kit@1.30.4
├── @zerodevx/svelte-img@2.1.0
├── canvas@2.11.2
├── eslint-config-prettier@8.10.0
├── eslint-plugin-svelte3@4.0.0
├── eslint@8.57.0
├── ffmpeg-static@5.2.0
├── fluent-ffmpeg@2.1.2
├── mysql2@3.9.2
├── prettier-plugin-svelte@2.10.1
├── prettier@2.8.8
├── sass@1.71.1
├── svelte-markdown@0.4.1
├── svelte@4.2.12
└── vite@4.5.2
```

servers `node -v` output is `v18.17.1`, local is `v18.14.2`

any help appreciated!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.