Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Canvas not rending custom font in server side image generation

I am trying to use Canvas to generate images via an API because I need to programmatically generate images using a background image and overlaying custom text.

I am writing the server in Node JS.

Current implementation in "pages/api/image.js":

import "@fontsource/press-start-2p"; //Font I am trying to use -- successfully loads in React web UI
const { createCanvas, loadImage } = require("canvas");

export async function generateImage(body) {
      const canvas = createCanvas(width, height);
      const context = canvas.getContext("2d");
...
      context.drawImage(image, 0, 0, width, height); //draws background image - no problem
...
      context.font = "16pt Press Start 2P";          //Font defaults to other alternative
      context.fillText("Sample text", 40, 40); 

I cannot figure out if Canvas cannot support the custom font, or if I am loading the font incorrectly.

Does anyone have any tips on how to generate these images with the custom font? I am open to a non Canvas solution if that is a limitation of the package.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!