Skip to content

Commit

Permalink
open images in new widnow
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed Mar 8, 2024
1 parent 5818d55 commit fa4656c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 50 deletions.
42 changes: 7 additions & 35 deletions src/img/geltungsbereicheLegends/ga_legend_a4_de.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions src/utils/exportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,10 @@ export const exportPdf = async (

// Convert SVG to image
updatedSvg = new XMLSerializer().serializeToString(svgDoc);
// const blob = new Blob([updatedSvg], { type: "image/svg+xml" });
// const url = URL.createObjectURL(blob);
const blob = new Blob([updatedSvg], { type: "image/svg+xml" });
const url = URL.createObjectURL(blob);
// window.open(url, "_blank");
const image = await loadImage(
`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(updatedSvg)))}`,
);
const image = await loadImage(url);

// Add SVG to map canvas
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
Expand Down
23 changes: 13 additions & 10 deletions src/utils/fontUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ export const sbbWebThin = {
family: "SBBWeb-Thin",
file: SBBWebThinPath,
};

const cache = {};
export const getFontBase64FontFace = async (file, fontFamily) => {
const fontBase64 = await fetch(file)
.then((res) => res.blob())
.then((blob) => toBase64(blob));
return `
@font-face {
src: url(${fontBase64});
font-family: '${fontFamily}';
}
`;
if (!cache[fontFamily]) {
const fontBase64 = await fetch(file)
.then((res) => res.blob())
.then((blob) => toBase64(blob));
cache[fontFamily] = `
@font-face {
src: url(${fontBase64});
font-family: '${fontFamily}';
}
`;
}
return cache[fontFamily];
};

const sbbFontsBase64 = [
Expand Down

0 comments on commit fa4656c

Please sign in to comment.