Node Canvas fails to use registered font with SvelteKit app on Node server

32 Views Asked by At

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/[email protected]
├── @sveltejs/[email protected]
├── @sveltejs/[email protected]
├── @zerodevx/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

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

any help appreciated!

I've tried several changes to the fonts path, because I've thought, that the app can not access them. But as I've said above, it has access to them.

0

There are 0 best solutions below