Define default fonts for Gradio theme

Allows web UI to (almost) be ran fully offline.
The web UI will hang on load if offline when
these fonts are not manually defined, as it will attempt (and fail)
to pull from Google Fonts.
This commit is contained in:
catboxanon 2023-05-12 18:08:34 +00:00
parent b14e23529f
commit 867be74244

View File

@ -666,13 +666,19 @@ def reload_gradio_theme(theme_name=None):
theme_name = opts.gradio_theme theme_name = opts.gradio_theme
if theme_name == "Default": if theme_name == "Default":
gradio_theme = gr.themes.Default() gradio_theme = gr.themes.Default(
font=['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'],
font_mono=['IBM Plex Mono', 'ui-monospace', 'Consolas', 'monospace'],
)
else: else:
try: try:
gradio_theme = gr.themes.ThemeClass.from_hub(theme_name) gradio_theme = gr.themes.ThemeClass.from_hub(theme_name)
except Exception as e: except Exception as e:
errors.display(e, "changing gradio theme") errors.display(e, "changing gradio theme")
gradio_theme = gr.themes.Default() gradio_theme = gr.themes.Default(
font=['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'],
font_mono=['IBM Plex Mono', 'ui-monospace', 'Consolas', 'monospace'],
)