Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda