Skip to content

Download as PNG + import {rasterize, serialize} from "@mbostock/saving-svg" #2018

Closed Answered by BMPMS
BMPMS asked this question in Q&A
Discussion options

You must be logged in to vote

Makes sense. Just trying to do a very specific one off task.. I've managed to solve it by adding the following to your serialize function.

const style = document.createElementNS(svgns, "style");
style.setAttribute("type", "text/css");
style.textContent = `
body, svg {
    font-family: 'PetitaLight', sans-serif;

}
`;
svg.insertBefore(style, svg.firstChild);

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Fil
Comment options

Fil Aug 19, 2025
Collaborator

Comment options

You must be logged in to vote
0 replies
Answer selected by Fil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants