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 20712da commit d5cc52a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
6 changes: 5 additions & 1 deletion src/utils/exportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ const getStyleWithForceVisibility = (
const loadImage = (src) =>
new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onload = () => {
window.setTimeout(() => {
resolve(img);
}, 5000);
};
img.onerror = reject;
img.src = src;
});
Expand Down
51 changes: 21 additions & 30 deletions src/utils/fontUtils.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import toBase64 from "./toBase64";
// import SBBWebRomanPath from "./fonts/SBBWeb-Roman.ttf";
// import SBBWebLightPath from "./fonts/SBBWeb-Light.ttf";
import SBBWebBoldPath from "./fonts/SBBWeb-Bold.ttf";
import SBBWebItalicPath from "./fonts/SBBWeb-Italic.ttf";
import SBBWebUltraLightPath from "./fonts/SBBWeb-UltraLight.ttf";
import SBBWebThinPath from "./fonts/SBBWeb-Thin.ttf";
import SBBWebRomanPath from "./fonts/SBBWeb-Roman.woff";
import SBBWebLightPath from "./fonts/SBBWeb-Light.woff";
import SBBWebBoldPath from "./fonts/SBBWeb-Bold.woff";
import SBBWebItalicPath from "./fonts/SBBWeb-Italic.woff";
import SBBWebUltraLightPath from "./fonts/SBBWeb-UltraLight.woff";
import SBBWebThinPath from "./fonts/SBBWeb-Thin.woff";

export const sbbWebRoman = {
// family: "SBBWeb-Roman",
// file: SBBWebRomanPath,

family: "SBBWeb-Roman",
file: "https://cdn.app.sbb.ch/fonts/v1_6_subset/SBBWeb-Roman.woff",
file: SBBWebRomanPath,
};

export const sbbWebLight = {
family: "SBBWeb-Light",
file: "https://cdn.app.sbb.ch/fonts/v1_6_subset/SBBWeb-Light.woff",
file: SBBWebLightPath,
};

export const sbbWebUltraLight = {
Expand All @@ -39,31 +36,25 @@ export const sbbWebThin = {
file: SBBWebThinPath,
};

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

const sbbFontsBase64 = [
sbbWebRoman,
sbbWebLight,
// sbbWebUltraLight,
// sbbWebBold,
// sbbWebItalic,
// sbbWebThin,
sbbWebUltraLight,
sbbWebBold,
sbbWebItalic,
sbbWebThin,
];

export const getSBBFontsDefinition = async () => {
Expand Down

0 comments on commit d5cc52a

Please sign in to comment.