I am trying to generate a word cloud using d3-cloud from nodejs. Starting from the example/node.js, I believe I have to get the SVG from the canvas.toBuffer(), which also requires creating the canvas with third argument "svg". But I get a segmentation fault.
I'm able to run the stock example/node.js. I can also add a line in the end() function to save cv.toBuffer() to a file, and it is indeed a PNG with what looks like words.
So I modified example/node.js further to initialize for SVG output:
Now if I run it, there is a segfault. If I run it in debug mode, the segfault occurs when calling start(). If I remove the "svg", there is no segfault (but the toBuffer() then returns PNG instead of SVG).
I verified that the problem is not cairo/canvas support for SVG:
var fs = require("fs")
var Canvas = require("canvas")
var canvas = new Canvas(200,200,"svg")
var ctx = canvas.getContext("2d")
ctx.fillRect(0,0,100,100) //Black square
ctx.save()
ctx.fillStyle = "darkblue"
ctx.fillRect(0,0,100,100) //Blue square
fs.writeFileSync("square1.svg", canvas.toBuffer()) //Saves blue square. Ok
I am trying to generate a word cloud using d3-cloud from nodejs. Starting from the example/node.js, I believe I have to get the SVG from the canvas.toBuffer(), which also requires creating the canvas with third argument "svg". But I get a segmentation fault.
I'm able to run the stock example/node.js. I can also add a line in the end() function to save cv.toBuffer() to a file, and it is indeed a PNG with what looks like words.
So I modified example/node.js further to initialize for SVG output:
Now if I run it, there is a segfault. If I run it in debug mode, the segfault occurs when calling start(). If I remove the "svg", there is no segfault (but the toBuffer() then returns PNG instead of SVG).
I verified that the problem is not cairo/canvas support for SVG:
The square1.svg contains xml in SVG format.
Any ideas?