I've implemented a customized version of svg-edit with svg-font-loader on top of it. When the user is editing an SVG file, the custom fonts work well thanks to svg-font-loader (I simply pre-load the necessary custom font on the editor before loading the SVG string).
Once the user has finished with editing, I save the new SVG string to the file system (using XDocument's
Parse()
and Save()
.
I then need to display this SVG file to the user inside an <img>
tag, but the fonts don't work unless the user installs them on their machine.
How can I encode the SVG string (Base64 or?) before saving to the file system, so that it displays correctly? Would I need to parse the SVG string and only encode certain parts? Is there a tool I can use?
edit: Alternatively, if I install the fonts on the server, is there a way to serialize the SVG to PNG on the server-side, and then display this? Would this work?