@@ -10,9 +10,9 @@ import { isDevEnvironment } from "./utils/env";
1010import { isCustomTextLong } from "./legacy-states/custom-text-name" ;
1111import { canQuickRestart } from "./utils/quick-restart" ;
1212import { FontName } from "@monkeytype/schemas/fonts" ;
13- import { applyFontFamily } from "./controllers/theme-controller" ;
1413import { qs , qsr } from "./utils/dom" ;
1514import { createEffect } from "solid-js" ;
15+ import fileStorage from "./utils/file-storage" ;
1616import { convertRemToPixels } from "./utils/numbers" ;
1717
1818let isPreviewingFont = false ;
@@ -27,6 +27,32 @@ export function previewFontFamily(font: FontName): void {
2727 isPreviewingFont = true ;
2828}
2929
30+ export async function applyFontFamily ( ) : Promise < void > {
31+ let font = Config . fontFamily . replace ( / _ / g, " " ) ;
32+
33+ const localFont = await fileStorage . getFile ( "LocalFontFamilyFile" ) ;
34+ if ( localFont === undefined ) {
35+ //use config font
36+ qs ( ".customFont" ) ?. empty ( ) ;
37+ } else {
38+ font = "LOCALCUSTOM" ;
39+
40+ qs ( ".customFont" ) ?. setHtml ( `
41+ @font-face{
42+ font-family: LOCALCUSTOM;
43+ src: url(${ localFont } );
44+ font-weight: 400;
45+ font-style: normal;
46+ font-display: block;
47+ }` ) ;
48+ }
49+
50+ document . documentElement . style . setProperty (
51+ "--font" ,
52+ `"${ font } ", "Roboto Mono", "Vazirharf", monospace` ,
53+ ) ;
54+ }
55+
3056export function clearFontPreview ( ) : void {
3157 if ( ! isPreviewingFont ) return ;
3258 previewFontFamily ( Config . fontFamily ) ;
0 commit comments