diff --git a/src/lib/components/actions.svelte b/src/lib/components/actions.svelte
index 9f5f72bd..ed3d8cfd 100644
--- a/src/lib/components/actions.svelte
+++ b/src/lib/components/actions.svelte
@@ -14,7 +14,7 @@
svg?.setAttribute('height', `${height}px`);
svg?.setAttribute('width', `${width}px`); // Workaround https://stackoverflow.com/questions/28690643/firefox-error-rendering-an-svg-image-to-html5-canvas-with-drawimage
if (!svg) {
- svg = document.querySelector('#container svg');
+ svg = getSvgEl();
}
const svgString = svg.outerHTML
.replaceAll('
', '
')
@@ -24,7 +24,7 @@
const exportImage = (event: Event, exporter: Exporter) => {
const canvas: HTMLCanvasElement = document.createElement('canvas');
- const svg: HTMLElement = document.querySelector('#container svg');
+ const svg: HTMLElement = getSvgEl();
const box: DOMRect = svg.getBoundingClientRect();
canvas.width = box.width;
canvas.height = box.height;
@@ -50,6 +50,22 @@
event.preventDefault();
};
+ const getSvgEl = () => {
+ const svgEl: HTMLElement = document
+ .querySelector('#container svg')
+ .cloneNode(true) as HTMLElement;
+ const fontAwesomeCdnUrl = Array.from(document.head.getElementsByTagName('link'))
+ .map((l) => l.href)
+ .find((h) => h && h.includes('font-awesome'));
+ if (fontAwesomeCdnUrl == null) {
+ return svgEl;
+ }
+ const styleEl = document.createElement('style');
+ styleEl.innerText = `@import url("${fontAwesomeCdnUrl}");'`;
+ svgEl.prepend(styleEl);
+ return svgEl;
+ };
+
const simulateDownload = (download: string, href: string): void => {
const a = document.createElement('a');
a.download = download;
diff --git a/yarn.lock b/yarn.lock
index c5bd6430..7b31deb9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -728,9 +728,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001335:
- version "1.0.30001356"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001356.tgz"
- integrity sha512-/30854bktMLhxtjieIxsrJBfs2gTM1pel6MXKF3K+RdIVJZcsn2A2QdhsuR4/p9+R204fZw0zCBBhktX8xWuyQ==
+ version "1.0.30001358"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001358.tgz"
+ integrity sha512-hvp8PSRymk85R20bsDra7ZTCpSVGN/PAz9pSAjPSjKC+rNmnUk5vCRgJwiTT/O4feQ/yu/drvZYpKxxhbFuChw==
caseless@~0.12.0:
version "0.12.0"