1+ <style >html .fonts-loading {visibility :hidden ;opacity :0 }</style >
2+ <script >document .documentElement .classList .add (' fonts-loading' );</script >
3+
4+ <link rel =" preload" href =" {{{ uiRootPath }}} /font/NotoSansDisplay.woff2" as =" font" type =" font/woff2" crossorigin =" anonymous" />
5+ <link rel =" preload" href =" {{{ uiRootPath }}} /font/NotoSansDisplay-Italic.woff2" as =" font" type =" font/woff2" crossorigin =" anonymous" />
6+ <link rel =" preload" href =" {{{ uiRootPath }}} /font/MonaspaceNeon-Var.woff2" as =" font" type =" font/woff2" crossorigin =" anonymous" />
7+ <link rel =" preload" href =" {{{ uiRootPath }}} /font/MonaspaceXenon-Var.woff2" as =" font" type =" font/woff2" crossorigin =" anonymous" />
8+
9+ <script >
10+ (function () {
11+ ' use strict' ;
12+
13+ var revealed = false ;
14+
15+ var reveal = function () {
16+ if (revealed) return ;
17+ revealed = true ;
18+ document .documentElement .classList .remove (' fonts-loading' );
19+ };
20+
21+ setTimeout (reveal, 3000 );
22+
23+ if (! (' FontFace' in window ) || ! (' fonts' in document )) {
24+ setTimeout (reveal, 100 );
25+ return ;
26+ }
27+
28+ var uiRoot = ' {{{uiRootPath}}}' ;
29+ var fonts = [
30+ {
31+ family: ' Noto Sans' ,
32+ url: uiRoot + ' /font/NotoSansDisplay.woff2' ,
33+ descriptors: { style: ' normal' , weight: ' 100 900' , stretch: ' 62.5% 100%' }
34+ },
35+ {
36+ family: ' Noto Sans' ,
37+ url: uiRoot + ' /font/NotoSansDisplay-Italic.woff2' ,
38+ descriptors: { style: ' italic' , weight: ' 100 900' , stretch: ' 62.5% 100%' }
39+ },
40+ {
41+ family: ' Monaspace Neon' ,
42+ url: uiRoot + ' /font/MonaspaceNeon-Var.woff2' ,
43+ descriptors: { style: ' normal' , weight: ' 400' }
44+ },
45+ {
46+ family: ' Monaspace Xenon' ,
47+ url: uiRoot + ' /font/MonaspaceXenon-Var.woff2' ,
48+ descriptors: { style: ' italic' , weight: ' 400' }
49+ }
50+ ];
51+
52+ var loadPromises = fonts .map (function (f ) {
53+ try {
54+ var face = new FontFace (f .family , ' url("' + f .url + ' ")' , f .descriptors );
55+ return face .load ().then (function (loaded ) {
56+ document .fonts .add (loaded);
57+ return loaded;
58+ }).catch (function () {
59+ return null ;
60+ });
61+ } catch (e) {
62+ return Promise .resolve (null );
63+ }
64+ });
65+
66+ Promise .all (loadPromises)
67+ .then (function () {
68+ return document .fonts .ready ;
69+ })
70+ .then (reveal)
71+ .catch (reveal);
72+ })();
73+ </script >
0 commit comments