File tree Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,32 @@ const customIconsMeta = document.querySelector('meta[name="gtt-font-custom-icons
13
13
const customIconsUrl = customIconsMeta ? customIconsMeta . getAttribute ( 'content' ) : 'data:application/font-woff2;base64,' ; // Provide a data URL for an empty font
14
14
15
15
// 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
+ }
25
28
}
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
+ }
28
42
29
43
// Define the font face
30
44
let customFont : FontFace ;
Original file line number Diff line number Diff line change 1
- /* @font-face {
1
+ @font-face {
2
2
font-family : "custom-icons" ;
3
3
font-style : normal;
4
4
font-weight : 400 ;
5
5
font-display : block;
6
6
src : url ("./custom-icons.woff2" ) format ("woff2" );
7
- } */
7
+ }
8
8
9
9
.custom-icons {
10
10
font-weight : normal;
You can’t perform that action at this time.
0 commit comments