Automattic/node-canvas — pull request #465 by espadrine (2014-08-30 08:51:24+00:00)
Title: Support SVG output

Very similarly to how node-canvas supports PDF output, supporting SVG gives huge interesting opportunities.

- Getting SVG paths from text of a specific font (instead of resorting to web-safe fonts),
- Generating customized SVG images server-side, which saves more bandwidth the larger the image *and* doesn't have that zooming / retina / 2x / \ issue,
- Computing SVG images to be inserted in the middle of your HTML page, which makes it part of the DOM and can be animated by a nearby script.

Overall, adding SVG was smooth. There was a tricky bit however. Since, unlike PDFs, cairo doesn't support dynamically changing the size of the display, the next obvious choice was to resort to using cairo's recordable surfaces. However, they do not look as good, for some unfathomable reason:

Direct SVG output:
![canvas-normal](https://cloud.githubusercontent.com/assets/100689/4098419/fc1e061a-301d-11e4-8899-1a7c18c20497.png)

Recorded surface, repainted on an SVG output:
![canvas-dirty](https://cloud.githubusercontent.com/assets/100689/4098420/0f936b9a-301e-11e4-9277-041333eb787a.png)

So I chose to delete and recreate the SVG surface every time instead.