Skip to content

Commit

Permalink
Fix Safari export not including custom fonts [#42]
Browse files Browse the repository at this point in the history
  • Loading branch information
davidje13 committed Jan 22, 2018
1 parent 326168b commit 8344ab2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/sequence-diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -5839,14 +5839,23 @@ define('sequence/Exporter',[],() => {
document.body.appendChild(safariHackaround);
}

img.addEventListener('load', () => {
const render = () => {
this.canvas.width = width;
this.canvas.height = height;
this.context.drawImage(img, 0, 0);
if(safariHackaround) {
document.body.removeChild(safariHackaround);
}
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});

img.src = this.getSVGURL(renderer, {width, height});
Expand Down
2 changes: 1 addition & 1 deletion lib/sequence-diagram.min.js

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion scripts/sequence/Exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,23 @@ define(() => {
document.body.appendChild(safariHackaround);
}

img.addEventListener('load', () => {
const render = () => {
this.canvas.width = width;
this.canvas.height = height;
this.context.drawImage(img, 0, 0);
if(safariHackaround) {
document.body.removeChild(safariHackaround);
}
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});

img.src = this.getSVGURL(renderer, {width, height});
Expand Down

0 comments on commit 8344ab2

Please sign in to comment.