Fix Safari export not including custom fonts [#42]

This commit is contained in:
David Evans 2018-01-22 20:17:31 +00:00
parent 326168b77d
commit 8344ab2a44
3 changed files with 21 additions and 3 deletions

View File

@ -5839,7 +5839,7 @@ define('sequence/Exporter',[],() => {
document.body.appendChild(safariHackaround); document.body.appendChild(safariHackaround);
} }
img.addEventListener('load', () => { const render = () => {
this.canvas.width = width; this.canvas.width = width;
this.canvas.height = height; this.canvas.height = height;
this.context.drawImage(img, 0, 0); this.context.drawImage(img, 0, 0);
@ -5847,6 +5847,15 @@ define('sequence/Exporter',[],() => {
document.body.removeChild(safariHackaround); document.body.removeChild(safariHackaround);
} }
this.canvas.toBlob(callback, 'image/png'); this.canvas.toBlob(callback, 'image/png');
};
img.addEventListener('load', () => {
if(safariHackaround) {
// Wait for custom fonts to load (Safari takes a moment)
setTimeout(render, 50);
} else {
render();
}
}, {once: true}); }, {once: true});
img.src = this.getSVGURL(renderer, {width, height}); img.src = this.getSVGURL(renderer, {width, height});

File diff suppressed because one or more lines are too long

View File

@ -80,7 +80,7 @@ define(() => {
document.body.appendChild(safariHackaround); document.body.appendChild(safariHackaround);
} }
img.addEventListener('load', () => { const render = () => {
this.canvas.width = width; this.canvas.width = width;
this.canvas.height = height; this.canvas.height = height;
this.context.drawImage(img, 0, 0); this.context.drawImage(img, 0, 0);
@ -88,6 +88,15 @@ define(() => {
document.body.removeChild(safariHackaround); document.body.removeChild(safariHackaround);
} }
this.canvas.toBlob(callback, 'image/png'); this.canvas.toBlob(callback, 'image/png');
};
img.addEventListener('load', () => {
if(safariHackaround) {
// Wait for custom fonts to load (Safari takes a moment)
setTimeout(render, 50);
} else {
render();
}
}, {once: true}); }, {once: true});
img.src = this.getSVGURL(renderer, {width, height}); img.src = this.getSVGURL(renderer, {width, height});