fix(theme): don't crash the app on invalid fonts

This commit is contained in:
Paul Makles 2022-01-31 01:04:13 +00:00
parent 334e54146b
commit edaf2256d5

View file

@ -330,13 +330,21 @@ export default observer(() => {
useEffect(() => {
const font = theme.getFont() ?? DEFAULT_FONT;
root.setProperty("--font", `"${font}"`);
FONTS[font].load();
try {
FONTS[font].load();
} catch (err) {
console.error(`Failed to load font: ${font}`);
}
}, [root, theme.getFont()]);
useEffect(() => {
const font = theme.getMonospaceFont() ?? DEFAULT_MONO_FONT;
root.setProperty("--monospace-font", `"${font}"`);
MONOSPACE_FONTS[font].load();
try {
MONOSPACE_FONTS[font].load();
} catch (err) {
console.error(`Failed to load monospace font: ${font}`);
}
}, [root, theme.getMonospaceFont()]);
useEffect(() => {