Automattic / Automattic/node-canvas
v4.0.0-rc3: SVG text rendering not working
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
Minimal reproduction:
```js
import { createCanvas, loadImage } from 'canvas'
const 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](https://github.com/iamlemec/node-canvas/tree/svg-text) and [lunasvg](https://github.com/iamlemec/lunasvg/tree/svg-text).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the minimal reproduction using createCanvas, loadImage, and drawImage, then trace the lunasvg SVG text path and compare its callbacks with the existing fillText functions. Done means SVG text renders instead of producing a blank image, with coverage added for SVG plus text rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100