Import a font to use it with node-canvas

Say the URL for your font is: https://example.com/myFont.ttf and you want to download that into your project. To do so you should open the glitch console and write: curl https://example.com/myFont.ttf > /app/myFont.ttf.

In your code where you use node-canvas you simply register the font like this:

const {registerFont, createCanvas} = require("canvas")
registerFont("/app/myFont.ttf", { family: "myFont" })
const canvas = createCanvas(500, 500);
const ctx = canvas.getContext("2d");
ctx.font = "12px 'myFont'";
// ...