From 1a7851c5125b7dd2bccf9f3f1ead38be5da2c9ad Mon Sep 17 00:00:00 2001 From: Scott Davidson <49713135+sd109@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:52:56 +0100 Subject: [PATCH] Fix handling of single font name in theme (#7967) * 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 Co-authored-by: Ali Abid --- .changeset/yummy-rocks-relax.md | 5 +++++ gradio/themes/base.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/yummy-rocks-relax.md diff --git a/.changeset/yummy-rocks-relax.md b/.changeset/yummy-rocks-relax.md new file mode 100644 index 0000000000..bf6717e2bb --- /dev/null +++ b/.changeset/yummy-rocks-relax.md @@ -0,0 +1,5 @@ +--- +"gradio": minor +--- + +feat:Fix handling of single font name in theme diff --git a/gradio/themes/base.py b/gradio/themes/base.py index 131f8871fa..c5463bbef8 100644 --- a/gradio/themes/base.py +++ b/gradio/themes/base.py @@ -462,13 +462,13 @@ class Base(ThemeClass): 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)