v4.0.0-rc3: SVG text rendering not working
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript, node.js
- Domain
- computer-graphics
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.
Description
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.
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Automattic/node-canvas
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/node-canvas#2633 ·
-
Feature Text & Fonts
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Automattic/node-canvas#2364 · 3 comments · 2 reactions ·
-
Feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Automattic/node-canvas#2621 ·
-
actualBoundingBoxLeft has the sign inverted relative to canvas's own rasteriser (3.2.0, 3.2.3)Possibly taken @florianaltendorfer claimed this 13 days ago. OpenBug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Automattic/node-canvas#2620 · 1 comment ·
-
The PDF file created by createPDFStream becomes larger in size, and createWriteStream is very slowOpenBug performance
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Automattic/node-canvas#2615 · 2 comments ·
All issues in Automattic/node-canvas
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
capricorn86/happy-dom#2594 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
microsoft/monaco-editor#5575 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Shrinking an array with `length =` and growing it back loses the patches for the truncated indicesPossibly taken @RClaudiuM claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 4 days