Skip to content

Commit

Permalink
Fix handling of single font name in theme (#7967)
Browse files Browse the repository at this point in the history
* Fix handling of single font name in theme

Previous check failed because `str` is an instance of Iterable so was never correctly wrapped in `[...]`. Instead, providing a single font such as "Arial" would result in a font list of "A, r, i, a, l" in the bundled CSS.

* Handle single fonts.Font instance correctly

* add changeset

* changes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Ali Abid <aliabid94@gmail.com>
  • Loading branch information
3 people committed Apr 8, 2024
1 parent 7c9a964 commit 1a7851c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/yummy-rocks-relax.md
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:Fix handling of single font name in theme
4 changes: 2 additions & 2 deletions gradio/themes/base.py
Expand Up @@ -462,13 +462,13 @@ def expand_shortcut(shortcut, mode="color", prefix=None):
self.text_xxl = text_size.xxl

# Font
if not isinstance(font, Iterable):
if isinstance(font, (fonts.Font, str)):
font = [font]
self._font = [
fontfam if isinstance(fontfam, fonts.Font) else fonts.Font(fontfam)
for fontfam in font
]
if not isinstance(font_mono, Iterable):
if isinstance(font, fonts.Font) or isinstance(font_mono, str):
font_mono = [font_mono]
self._font_mono = [
fontfam if isinstance(fontfam, fonts.Font) else fonts.Font(fontfam)
Expand Down

0 comments on commit 1a7851c

Please sign in to comment.