v4.0.0-rc3: SVG text rendering not working
Author: iamlemecCreated Aug 30, 2026Updated Aug 30, 2026
LabelsBug
Minimal reproduction:
import { createCanvas, loadImage } from 'canvas'
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100">
<text x="10" y="60" font-family="sans-serif" font-size="40" fill="red">Hello</text>
</svg>`
const img = await loadImage(Buffer.from(svg))
const canvas = createCanvas(200, 100)
const ctx = canvas.getContext('2d')
ctx.drawImage(img, 0, 0)Resulting in a blank output image.
The issue is that the retriever/measurer/painter callbacks are not set when using lunasvg. So it gets no font data, and even if it did, the text would not be measured or painted. There are also no SVG + text tests.
I have a fix ready as well, two PRs: one here and one in the lunasvg fork. Basically it hooks these callbacks up and pipes them to the existing functions used in fillText. Just want to make sure this is a real issue before proceeding.
See forks here: node-canvas and lunasvg.
Source: Automattic/node-canvas