Attempt to fix Safari rendering of SVGs

This commit is contained in:
Shawn 2018-12-01 01:34:45 -06:00
parent b5c8cbec52
commit ade68b217c

View file

@ -28,6 +28,11 @@ const getRasterizedCanvas = (contents, width, height) => {
); );
} }
// Fix busted SVG images in Safari
if(/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)) {
contents = contents.replace(/\<img\s/g, '<xhtml:img ');
}
// Attempt to match font kerning with the DOM. // Attempt to match font kerning with the DOM.
const kerningAndPadding = '<style>svg{font-kerning:normal}body{padding:0;margin:0}</style>'; const kerningAndPadding = '<style>svg{font-kerning:normal}body{padding:0;margin:0}</style>';
let svgContents = `<svg xmlns="http://www.w3.org/2000/svg" width="${width * 2}" height="${height * 2}"> let svgContents = `<svg xmlns="http://www.w3.org/2000/svg" width="${width * 2}" height="${height * 2}">