Ah, i was wrong about the library I was using -- it was this one: save-svg-as-png
I see now they have support for a list of fonts, so quite possibly that would be enough to fix my old code. Unfortunately, the work was done against an old v1.9.x version of node-red -- but here is the function I added to editor/js/view.js in order to invoke the library:
function savePng() {
var editor = document.querySelector("#workspace #chart");
// get the bounds of the visible area, inside the scroll bars
var bounds = { height: editor.clientHeight, width: editor.clientWidth };
//var bounds = editor.getBoundingClientRect();
var topsvg = editor.querySelector("svg");
// temporarily hide the grid, if shown
var gridon = grid.style("visibility") === "visible";
if (gridon) {
toggleShowGrid(false);
}
var active = RED.workspaces.active();
var acttab = RED.nodes.workspace(active);
var pngwin = window.open('', 'svgpng', "height=" + bounds.height + ",width=" + bounds.width + ",titlebar=no,location=no,resizable,menubar,tabbar,dialog");
svgAsPngUri(topsvg, {
height: bounds.height,
width: bounds.width,
scale: 1 / scaleFactor
},
function(pnguri) {
pngwin.document.head.innerHTML = "<title>" + acttab.label + "</title>";
pngwin.document.body.style = "margin: 0;";
pngwin.document.body.innerHTML = "<img src='" + pnguri + "'/>";
// redisplay the grid, if shown
if (gridon) {
toggleShowGrid(true);
}
});
}
The window that is opened (see the image in my previous post) shows only the "visible" part of the editor canvas (i.e. you have to zoom into the section to be converted), not the entire 5000px wide editor canvas. But the image can them be copied to the clipboard, saved as a file, or sent directly to the printer from the popup browser window.