Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fonts loading #9888

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/grumpy-snakes-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:Fix fonts loading
7 changes: 5 additions & 2 deletions gradio/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,11 @@ def get_config(request: fastapi.Request):

@app.get("/static/{path:path}")
def static_resource(path: str):
static_file = routes_safe_join(STATIC_PATH_LIB, UserProvidedPath(path))
return FileResponse(static_file)
if path.startswith(("fonts/ui-sans-serif/", "fonts/system-ui/")):
return Response(status_code=200)
else:
static_file = routes_safe_join(STATIC_PATH_LIB, UserProvidedPath(path))
return FileResponse(static_file)

@router.get("/custom_component/{id}/{environment}/{type}/{file_name}")
def custom_component_path(
Expand Down
4 changes: 2 additions & 2 deletions gradio/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,13 @@ def expand_shortcut(shortcut, mode="color", prefix=None):
if isinstance(font, (fonts.Font, str)):
font = [font]
self._font = [
fontfam if isinstance(fontfam, fonts.Font) else fonts.LocalFont(fontfam)
fontfam if isinstance(fontfam, fonts.Font) else fonts.Font(fontfam)
for fontfam in font
]
if isinstance(font_mono, (fonts.Font, str)):
font_mono = [font_mono]
self._font_mono = [
fontfam if isinstance(fontfam, fonts.Font) else fonts.LocalFont(fontfam)
fontfam if isinstance(fontfam, fonts.Font) else fonts.Font(fontfam)
for fontfam in font_mono
]
self.font = ", ".join(str(font) for font in self._font)
Expand Down
Loading