The notebook is a demo of behavior I noticed in another private notebook. That private notebook generates SVG which can be saved as a PNG via the rasterize function from @mbostock/saving-svg. In that private notebook, rasterization consistently excludes text elements from the rasterized output, and I’m having trouble figuring out what I’m doing wrong.
raster-svg uses Canvas to redraw SVG on a Canvas context, and browsers often take optimization steps to skip drawing steps that they believe won’t result in anything. For example, in Chrome a line of width 0.004 will render, but one at 0.003 won’t. If you set globalAlpha to c.globalAlpha = 0.001, then the following draw instructions are skipped, but at 0.002, a 0.2% alpha equivalent is used. In Chrome, a line of 0.0001 length won’t be rendered, one of 0.001 is rendered as a gradient along a line (surprise?), and 0.005 is rendered as a normal line.
So, the moral of the story is, well, there’s chaos at the extremes of the Canvas API - extremely short things, small things, and transparent things are liable to be rendered weirdly or not at all, even by mature browsers like Chrome. In this case, you’re likely running into another one of those cases, and I would mostly just recommend to use a larger viewBox and a larger SVG, so that the tricky places where your browser is running out of floating-point accuracy or making optimization decisions are avoided altogether.