Skip to content

Commit aaeee3e

Browse files
committed
Fixes missing font and wrong path issue
1 parent c3a75f3 commit aaeee3e

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/styles/icons/custom/custom-icons-def.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,32 @@ const customIconsMeta = document.querySelector('meta[name="gtt-font-custom-icons
1313
const customIconsUrl = customIconsMeta ? customIconsMeta.getAttribute('content') : 'data:application/font-woff2;base64,'; // Provide a data URL for an empty font
1414

1515
// Dynamically create the @font-face rule
16-
const style = document.createElement('style');
17-
style.type = 'text/css';
18-
style.innerHTML = `
19-
@font-face {
20-
font-family: 'custom-icons';
21-
font-style: normal;
22-
font-weight: 400;
23-
font-display: block;
24-
src: url(${customIconsUrl}) format('woff2');
16+
if (customIconsUrl) {
17+
// Remove the existing @font-face rule
18+
const styleSheets = document.styleSheets;
19+
for (let i = 0; i < styleSheets.length; i++) {
20+
const cssRules = styleSheets[i].cssRules || styleSheets[i].rules;
21+
for (let j = 0; j < cssRules.length; j++) {
22+
const rule = cssRules[j];
23+
if (rule instanceof CSSFontFaceRule && rule.style.fontFamily === 'custom-icons') {
24+
styleSheets[i].deleteRule(j);
25+
break;
26+
}
27+
}
2528
}
26-
`;
27-
document.head.appendChild(style);
29+
30+
const style = document.createElement('style');
31+
style.innerHTML = `
32+
@font-face {
33+
font-family: 'custom-icons';
34+
font-style: normal;
35+
font-weight: 400;
36+
font-display: block;
37+
src: url(${customIconsUrl}) format('woff2');
38+
}
39+
`;
40+
document.head.appendChild(style);
41+
}
2842

2943
// Define the font face
3044
let customFont: FontFace;

src/styles/icons/custom/custom-icons.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/* @font-face {
1+
@font-face {
22
font-family: "custom-icons";
33
font-style: normal;
44
font-weight: 400;
55
font-display: block;
66
src: url("./custom-icons.woff2") format("woff2");
7-
} */
7+
}
88

99
.custom-icons {
1010
font-weight: normal;

0 commit comments

Comments
 (0)